forked from wandering007/ProjectEuler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP57.java
More file actions
21 lines (21 loc) · 676 Bytes
/
P57.java
File metadata and controls
21 lines (21 loc) · 676 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import java.math.BigInteger;
public class P57
{
public static final int MAXN = 1000;
public static void main( String[] args )
{
long start = System.currentTimeMillis();
int num = 0;
BigInteger numerator = new BigInteger("1");
BigInteger denominator = new BigInteger("1");
for(int i = 1; i <= MAXN; i++)
{
numerator = numerator.add(denominator).add(denominator);
denominator = numerator.subtract(denominator);
if(numerator.toString().length() > denominator.toString().length())
num++;
}
System.out.println(num);
System.out.println("time cost: " + (System.currentTimeMillis() - start) + "ms");
}
}