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]);
}
}
}