Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么会编译错误呀(java),不是很懂,帮忙修改!!谢谢

Posted by ecjtubaowp at 2007-02-09 13:04:33 on Problem 3199
import java.io.*;
import java.util.*;
import java.math.*;
public class Main{
       static BigInteger S[][];
   public static int gcd(int n,int m)
   {
    if(m==0)return n;
    return gcd(m,n%m);
   }
   public static int cm(int n,int m)
   {
    int ans,i,k,i0,n0;
    if(m>n-m) m=n-m;
   ans=1;
   for(i=1;i<=m;i++,n--)
   {
      k=gcd(i,n);i0=i;n0=n;
      if(k>1){i0=i/k;n0=n/k;}
     ans=ans/i0*n0;
  }
  return ans;
   }
    public static BigInteger recur(int n,int k)
    {
        if(S[n][k]!=BigInteger.ZERO)return S[n][k];
        if(S[n-1][k-1]==BigInteger.ZERO)S[n-1][k-1]=recur(n-1,k-1);
        if(S[n-1][k]==BigInteger.ZERO)S[n-1][k]=recur(n-1,k);
        S[n][k]=S[n-1][k-1].add(S[n-1][k].multiply(k));
        return S[n][k];
    }//public
    public static void main(String[] args)
	{    S=new BigInteger[40][40];
	     int i,j,k;
	     int jiec[11];
	     jiec[1]=1;
	     for(i=2;i<=10;i++)
	     jiec[i]=jiec[i-1]*i;
	     for(i=1;i<=29;i++)
         {S[i][1]= BigInteger.ONE;
         S[i][i]= BigInteger.ONE;
         }
         for(i=3;i<=29;i++)
   {
      for(j=2;j<i;j++)
      {
         if(S[i-1][j-1]==BigInteger.ZERO)S[i-1][j-1]=recur(i-1,j-1);
         if(S[i-1][j]==BigInteger.ZERO)S[i-1][j]=recur(i-1,j);
         S[i][j]=S[i-1][j-1].add(S[i-1][j].multiply(j));
      }
   }
		Scanner sc = new Scanner(System.in);
		//stirling();
		while(sc.hasNextInt())
		{   int n = sc.nextInt();
		    int m = sc.nextInt();
            if(n==0&&m==0)break;
			BigInteger ans=BigInteger.ZERO;
			for(i=1;i<=n;i++)
			{k=jiec[i]*cm(n,i);
			ans=ans.add(S(m,i).multiply(k));
            }
            System.out.println(ans);
		}
	}

}//public



Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator