【HDU1223】Order Count(动态规划DP+java大数)

Categories: 数据结构和算法
Tags: ,
Comments: No Comments
Published on: 2011 年 05 月 11 日

If we connect 3 numbers with "<" and "=", there are 13 cases: 1) A=B=C 2) A=B
4) A import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; import java.math.BigInteger; import java.util.Scanner; public class Main { static BigInteger[][] f=new BigInteger[51][51]; public static void main(String[] args) throws FileNotFoundException { Scanner cin=new Scanner(System.in); init(); f[1][1]=BigInteger.valueOf(1); for(int i=2;i<=50;i++){ for(int j=1;j<=i;j++){ f[i][j]=f[i-1][j].add(f[i-1][j-1]).multiply(BigInteger.valueOf(j)); } } int t=cin.nextInt(); while(t--!=0){ int n=cin.nextInt(); println(n); } } static void init(){ for(int i=0;i<=50;i++){ for(int j=0;j<=50;j++) f[i][j]=BigInteger.ZERO; } } static void println(int n){ BigInteger big=BigInteger.ZERO; for(int i=1;i<=n;i++) big=big.add(f[n][i]); System.out.println(big.toString()); } }


No Comments - Leave a comment

Leave a comment

电子邮件地址不会被公开。 必填项已用*标注

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Welcome , today is 星期六, 2019 年 02 月 23 日