// UVa 10334 - Ray Through Glasses import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); BigInteger[] fib = new BigInteger[1001]; int m = 1; fib[0] = BigInteger.ONE; fib[1] = BigInteger.valueOf(2); while (scan.hasNextInt()) { int n = scan.nextInt(); while (m < n) { m++; fib[m] = fib[m - 1].add(fib[m - 2]); } System.out.println(fib[n]); } } }
No comments:
Post a Comment