| ||||||||||
| 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 | |||||||||
为什么用JAVA高精都过不了???不是说至少精确十二位就行了么~~~import java.math.*;
import java.io.*;
import java.util.*;
public class Main
{
public static void main(String[] args) throws IOException
{
Scanner cin=new Scanner(System.in);
int i,j,n;
BigInteger num[][]=new BigInteger[105][105],ans;
for(i=0;i<=100;i++)
for(j=0;j<=100;j++)
num[i][j]=BigInteger.ZERO;
num[1][1]=BigInteger.ONE;
for(i=2;i<=100;i++)
for(j=1;j<=i;j++)
{
num[i][j]=BigInteger.valueOf(j).multiply(num[i-1][j]);
num[i][j]=num[i][j].add(num[i-1][j-1]);
}
while(cin.hasNext())
{
ans=BigInteger.ZERO;
n=cin.nextInt();
if(n==0)
break;
for(i=1;i<=n;i++)
ans=ans.add(num[n][i]);
System.out.println(ans);
}
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator