注解
1、Java大数BigInteger。
2、递推关系。
代码
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int n = sc.nextInt();
BigInteger[] bi = new BigInteger[n+1];
if(n>=5){
bi[1] = BigInteger.ONE;
bi[2] = BigInteger.ONE;
bi[3] = BigInteger.ONE;
bi[4] = BigInteger.ONE;
for(int i=5; i<bi.length; i++){
bi[i] = bi[i-1].add(bi[i-2]).add(bi[i-3]).add(bi[i-4]);
}
System.out.println(bi[n]);
}
else{
System.out.println("1");
}
}
}
}