-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp099.java
More file actions
29 lines (24 loc) · 736 Bytes
/
p099.java
File metadata and controls
29 lines (24 loc) · 736 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package level04;
import org.junit.Test;
import lib.EulerTest;
public class p099 extends EulerTest {
/**
* Find the pair (a, b) from the specified pairs such that a^b is largest.
* <p>
* Since a^b > c^d if and only if b log(a) > d log(c), we compute the line number with the
* largest b log(a).
*/
@Test
public void test() {
long[][] readAsGrid = readAsGrid(",");
double maxLogValue = 0.0;
for (int i : range(readAsGrid.length)) {
double logValue = readAsGrid[i][1] * Math.log(readAsGrid[i][0]);
if (logValue > maxLogValue) {
maxLogValue = logValue;
ans = i + 1;
}
}
check(709);
}
}