Advertisement
Guest User

Untitled

a guest
Feb 17th, 2015
4,473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Numerics;
  6. class Solution
  7. {
  8.     static void Main(String[] args)
  9.     {
  10.         String elements = Console.ReadLine();
  11.         String[] split_elements = elements.Split(' ');
  12.         int a = Convert.ToInt32(split_elements[0]);
  13.         int b = Convert.ToInt32(split_elements[1]);
  14.         int n = Convert.ToInt32(split_elements[2]);
  15.         BigInteger b1 = new BigInteger(b);
  16.         BigInteger a1 = new BigInteger(a);
  17.         for (int i = 3; i < n + 1; i++)
  18.         {
  19.             BigInteger temp = BigInteger.Pow(b1, 2) + a1;
  20.             a1 = b1;
  21.             b1 = temp;
  22.         }
  23.         var ans = new List<BigInteger>();
  24.         var p10 = BigInteger.Pow(10, 100);
  25.         while (b1 != 0)
  26.         {
  27.             ans.Add(b1 % p10);
  28.             b1 /= p10;
  29.         }
  30.         Console.Write(ans[ans.Count - 1]);
  31.         var fmt = new string('0', 100);
  32.         for (var i = ans.Count - 2; i >= 0; i--)
  33.         {
  34.             var str = ans[i].ToString();
  35.             Console.Write("{0}{1}", fmt.Substring(0, 100 - str.Length), str);
  36.         }
  37.         Console.WriteLine();
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement