poj2680

递推+高精度

java做

View Code
import java.util.*;
import java.math.*;
import java.io.*;

public class Main {
public static void main(String[] args)
{
Scanner cin
= new Scanner(new BufferedInputStream(System.in));
BigInteger f[]
= new BigInteger[1005];
f[
0] = new BigInteger("0");
f[
1] = new BigInteger("1");
f[
2] = new BigInteger("1");
for (int i = 3; i <= 1001; i++)
f[i]
= f[i - 2].add(new BigInteger("2").pow(i - 2));
while (cin.hasNext())
{
int n = cin.nextInt();
System.out.println(f[n
- 1]);
}
}
}
posted @ 2011-09-13 08:28  金海峰  阅读(172)  评论(0编辑  收藏  举报