Hdu 3723 Card Game (JAVA, Cattleya number)

Source: Internet
Author: User

It is easy to think of the number of Cattleya, but the complexity of high precision is quite disgusting.

And then he killed it in Java seconds.

Import Java.math.biginteger;import Java.util.scanner;public class Main {static biginteger[] f=new biginteger[5005];     Static biginteger[] C=new biginteger[10005];          Static BigInteger MOD;     static void Init () {f[0]=biginteger.valueof (1);     for (int i=1;i<=5000;i++) {f[i]=f[i-1].multiply (biginteger.valueof (4*i-2));     F[i]=f[i].divide (biginteger.valueof (i+1));     } String str= "1";     for (int i=0;i<100;i++) str+= "0";     Mod=new BigInteger (str);     } public static void Main (string[] args) {init ();     Scanner cin=new Scanner (system.in);     while (Cin.hasnext ()) {int n=cin.nextint ();     C[0]=biginteger.valueof (1);     for (int i=1;i<=n;i++) {c[i]=c[i-1].multiply (biginteger.valueof (n-i+1));     C[i]=c[i].divide (biginteger.valueof (i));     } BigInteger ans=biginteger.valueof (0);     for (int i=0;i*2<=n;i++) {BigInteger tmp=c[i*2].mod (mod). Multiply (F[i].mod (mod));     Ans=ans.add (TMP);     Ans=ans.mod (MoD); } SYSTEM.OUt.println (ANS); }     }}

  

Hdu 3723 Card Game (JAVA, Cattleya number)

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.