Test instructions
There are n points in a circle, and the match of the N points is the Bong without a common point (these edges can only connect two points adjacent to one circle), and the number of matches is calculated.
Well, I won't analyze it. =_=||
Just a few numbers, find the law and find it satisfies the recursive relationship of the Fibonacci sequence, f (n) = f (n-1) + f (n-2)
Since will use Java's BigInteger, will not bother to write C's high precision.
1 ImportJava.io.*;2 ImportJava.util.*;3 Importjava.math.*;4 5 Public classMain6 {7 StaticPrintWriter out =NewPrintWriter (NewBufferedWriter (NewOutputStreamWriter (System.out));8 9 Public Static voidMain (String args[])throwsIOExceptionTen { OneBigInteger [] A =Newbiginteger[10002]; AA[3] =NewBigInteger ("4"); -A[4] =NewBigInteger ("7"); - for(inti = 5; I <= 10000; ++i) A[i] = A[i-1].add (a[i-2]); theScanner cin=NewScanner (system.in); - while(Cin.hasnext ()) - { - intn =cin.nextint (); + System.out.println (A[n]); - } + } A}code June
UVa 1646 (Recursive java large number) Edge case