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)