1 import java.util.*; 2 import java.math.*; 3 public class Main 4 { 5 public static void main(String []args) 6 { 7 Scanner cin=new Scanner(System.in); 8 int i,n; 9 while(cin.hasNext()) 10 { 11 n=cin.nextInt(); 12 BigInteger s1 = BigInteger.valueOf(1); 13 BigInteger s2 = BigInteger.valueOf(1); 14 BigInteger s3 = BigInteger.valueOf(1); 15 BigInteger s4 = BigInteger.valueOf(1); 16 BigInteger s5 = BigInteger.valueOf(1); 17 for(i=5;i<=n;i++) 18 { 19 s5 = s4.add(s3.add(s2.add(s1))); 20 s1=s2; 21 s2=s3; 22 s3=s4; 23 s4=s5; 24 } 25 System.out.println(s5); 26 } 27 } 28 }
果断的一个大数问题,担心自己用C或者C++过不了,果断用了Java来做,用Java做这种题,确实简单,也记下自己的脚印吧!