UVa 1646 (Recursive java large number) Edge case

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.