hdu 1250(java大数)

//java大数
import java.util.Scanner;
import java.math.BigInteger;

public class hdu1250
{
public static void main(String args[])
{
Scanner cin = new Scanner(System.in);
int n;
while (cin.hasNextInt())
{
n = cin.nextInt();
if (n <= 4)
{
System.out.println("1");
continue;
}
BigInteger f1 = new BigInteger("1");
BigInteger f2 = new BigInteger("1");
BigInteger f3 = new BigInteger("1");
BigInteger f4 = new BigInteger("1");
BigInteger f5 = new BigInteger("0");
for (int i=4; i<n; ++i)
{
f5 = f5.add(f1).add(f2).add(f3).add(f4).subtract(f5);
f1 = f2;
f2 = f3;
f3 = f4;
f4 = f5;
}
System.out.println(f5);
}
}
}

 

你可能感兴趣的:(java)