import java.util.Scanner; import java.math.BigInteger; /** * * @author Tafhim */ public class Main { public static void main(String[] args) { BigInteger[] fibs = new BigInteger[5004]; fibs[0] = BigInteger.ZERO; fibs[1] = BigInteger.ONE; for (int i=2 ; i<=5000 ; i++) { fibs[i] = fibs[i-1].add(fibs[i-2]); } Scanner input = new Scanner(System.in); int q; while (input.hasNext()) { q = input.nextInt(); System.out.printf("The Fibonacci number for %d is %d\n",q,fibs[q]); } } }
Friday, September 16, 2011
[UVa] 495 - Fibonacci Freeze
Subscribe to:
Post Comments (Atom)
Connect Rapoo MT750S with Linux (Tested on Manjaro)
I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...
-
I like coding a lot, keeps me glued to the PC for hours. For that reason it's a need to edit the Syntax Highlighter to suit my eyes for...
-
I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...
-
Install MinGW GCC Port on Windows. 1. Just go to this address [ http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/ ]...
No comments:
Post a Comment
Post your comment here. If you want to say something about programming problems, scripts, software etc, please try to be as descriptive as possible.