UVa : 10450


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package UVa_10450;

import java.math.BigInteger;
import java.util.Scanner;

/**
 *
 * @author Shahab
 */
public class Main {

      public static void main(String[] args) {
            // TODO code application logic here
            BigInteger fibo [] = new BigInteger [55];
            fibo [0] = BigInteger.ONE;
            fibo [1] = BigInteger.valueOf(2);

            for ( int i = 2; i < 53; i++ )
                  fibo [i] = fibo [i - 1].add(fibo [i - 2]);

            Scanner input = new Scanner (System.in);
            int testCase = input.nextInt();
            int cases = 0;

            while ( testCase-- != 0 ) {
                  int number = input.nextInt();
                  System.out.println ("Scenario #" + ++cases + ':');
                  System.out.println (fibo [number]);
                  System.out.println ();
            }
      }
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s