UVA 10254 十八 The Priest Mathematician

时间:2021-03-03 17:35:16
The Priest Mathematician

Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu

 import java.math.*;
import java.util.Scanner; public class Main {
public static void main(String args[]){ BigInteger f[] = new BigInteger[10010];
f[0] = BigInteger.valueOf(0);
f[1] = BigInteger.valueOf(1);
int i = 2;
int k=1;
while(i <= 10000){
BigInteger add = BigInteger.valueOf(1).shiftLeft(k);
for(int j=0; j<k+1 && i<=10000; ++j){
f[i] = f[i-1].add(add);
++i;
}
++k;
}
Scanner cin = new Scanner(System.in);
while(cin.hasNext()){
int n = cin.nextInt();
System.out.println(f[n]);
}
}
}