Max Power
問題(Code: MXP)
入力
The first line of input contains a positive integer n, not greater than 10000. In the second line you are given a set of positive integers ai separated by spaces, and in the third line – integers bi. All numbers in both sequences are not greater than 10000. It is guaranteed that all power values are different.
計算量
O(N)
ソースコード
#include <stdio.h>
#include <math.h>
int n, o, i;
double m, q, a[10001], b[10001];
int main(void) {
scanf("%d", &n);
{
for (i = 1; i <= n; ++i) scanf("%lf", &a[i]);
for (i = 1; i <= n; ++i) scanf("%lf", &b[i]);
m = log(a[1]) * b[1]; o = 1;
for (i = 2; i <= n; ++i) {
q = log(a[i]) * b[i];
if (m < q) m = q, o = i;
}
}
printf("%d\n", o);
return 0;
}
確認
済み