juanjo12x

Live_Archive_6270

Oct 5th, 2014
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1.  
  2.  
  3.   import java.io.PrintWriter;
  4.   import java.math.BigInteger;
  5.   import java.util.Scanner;
  6.  
  7. public class Main
  8. {
  9.     Scanner scan=new Scanner(System.in);
  10.     PrintWriter out=new PrintWriter(System.out);
  11.     BigInteger dp[]=new BigInteger[10005];
  12.     int n;
  13.     void init(){
  14.         dp[3]=BigInteger.valueOf(4);
  15.         dp[4]=BigInteger.valueOf(7);
  16.         for(int i=5;i<=10001;i++) dp[i]=dp[i-1].add(dp[i-2]);
  17.     }
  18.    
  19.     void empezar(){
  20.         init();
  21.         while(scan.hasNextInt()){
  22.              n=scan.nextInt();
  23.              out.println(dp[n]);
  24.              out.flush();
  25.          }
  26.     }
  27.     public static void main (String[] args) throws java.lang.Exception
  28.     {
  29.         new Main().empezar();
  30.     }
  31. }
Add Comment
Please, Sign In to add comment