BZOJ1002 [FJOI2007] rotavirus

Source: Internet
Author: User

Can find the law, the title of the approximate meaning is to find the number of different spanning tree of the given graph

Can find an answer of N from 1 to 10 o'clock

1 5 16 45 121 320 841 2205 5776 15125

Rule is

Set odd[] as the square root of odd items

Then odd[i] = Odd[i-1]*3-odd[i-2]; (i>=3)

The number of even items divided by 5 can also get the above rule.

At last, run with high precision.

C + + basic is within 10ms, Java 880ms ....

1 ImportJava.io.*;2 ImportJava.util.*;3 Importjava.math.*;4 classMain5 {6      Public Static voidMain (String args[]) {7Scanner cin =NewScanner (system.in);8         intn =cin.nextint ();9BigInteger odd[] =Newbiginteger[105];TenBigInteger even[] =Newbiginteger[105]; OneODD[1] = even[1] =Biginteger.one; AODD[2] =NewBigInteger ("4"); -EVEN[2] =NewBigInteger ("3"); -          for(inti = 3;i<=51;++i) theOdd[i] = odd[i-1].multiply (even[2]). Subtract (odd[i-2]); -          for(inti = 3;i<=51;++i) -Even[i] = even[i-1].multiply (even[2]). Subtract (even[i-2]); -         if(n%2==1) System.out.println (odd[(n+1)/2].multiply (odd[(n+1)/2])); +         ElseSystem.out.println (Even[n/2].multiply (EVEN[N/2]). Multiply (NewBigInteger ("5"))); -     } +}

BZOJ1002 [FJOI2007] rotavirus

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.