Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
试试BufferedReaderIn Reply To:求助:怎么会超时啊?1000 100的结果都能很快出来 Posted by:newstar04415 at 2008-02-28 15:28:27 > import java.util.*; > import java.math.BigInteger; > public class Main > { > public static void main(String args[]) > { > int n,k,b,i,j; > BigInteger num[][]=new BigInteger[1001][101]; > BigInteger zero=new BigInteger("0"); > for(i=1;i<=1000;i++) > for(j=1;j<=100;j++) > num[i][j]=zero; > for(i=1;i<=1000;i++) > { > for(j=1;j<=100;j++) > { > if((i==j)||(j==1)) > num[i][j]=new BigInteger("1"); > > else if(i>j) > { > for(b=1;b<=j;b++) > num[i][j]=num[i][j].add(num[i-j][b]); > } > } > } > Scanner sc = new Scanner(System.in); > n=sc.nextInt(); > k=sc.nextInt(); > BigInteger sum=new BigInteger("0"); > for(i=1;i<=k;i++) > sum=sum.add(num[n][i]); > System.out.println(sum); > > } > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator