[ACM]Q10334: Ray Through Glasses

[ACM]Q10334: Ray Through Glasses


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

namespace Q10334
{
    class Program
    {
        static private BigInteger[] fib; static private int n; static private bool ntof;
        static void Main(string[] args)
        {
            for (; ; )
            {
            labeln: Console.Write("n>>>");
                ntof = int.TryParse(Console.ReadLine(), out n);
                if (!ntof) goto labeln;
                if (n == 0 ) { Console.WriteLine("Ans={0}", 1); goto labeln; }
                fib = new BigInteger[n+1];
                fib[0] = 1; fib[1] = 2;
                for (int i = 2; i <= n; i++)
                    fib[i] = fib[i - 1] + fib[i - 2];
                Console.WriteLine("Ans={0}", fib[n]);
            }
        }
    }
}