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 bingshen at 2011-02-13 20:13:59 on Problem 2325
import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String arg[])
	{
		Scanner cin=new Scanner(System.in);
		BigInteger n;
		int i;
		int prime[]=new int[8];
		while(true)
		{
			n=cin.nextBigInteger();
			if(n.compareTo(BigInteger.valueOf(0))==-1)
				break;
			for(i=0;i<8;i++)
				prime[i]=0;
			if(n.compareTo(BigInteger.valueOf(10))<0)
			{
				System.out.println(n.add(BigInteger.valueOf(10)));
				continue;
			}
			while(true)
			{
				if(n.mod(BigInteger.valueOf(9))!=BigInteger.valueOf(0))
					break;
				n=n.divide(BigInteger.valueOf(9));
				prime[7]=prime[7]+1;
			}
			while(true)
			{
				if(n.mod(BigInteger.valueOf(8))!=BigInteger.valueOf(0))
					break;
				n=n.divide(BigInteger.valueOf(8));
				prime[6]=prime[6]+1;
			}
			while(true)
			{
				if(n.mod(BigInteger.valueOf(7))!=BigInteger.valueOf(0))
					break;
				n=n.divide(BigInteger.valueOf(7));
				prime[5]=prime[5]+1;
			}
			while(true)
			{
				if(n.mod(BigInteger.valueOf(6))!=BigInteger.valueOf(0))
					break;
				n=n.divide(BigInteger.valueOf(6));
				prime[4]=prime[4]+1;
			}
			while(true)
			{
				if(n.mod(BigInteger.valueOf(5))!=BigInteger.valueOf(0))
					break;
				n=n.divide(BigInteger.valueOf(5));
				prime[3]=prime[3]+1;
			}
			while(true)
			{
				if(n.mod(BigInteger.valueOf(4))!=BigInteger.valueOf(0))
					break;
				n=n.divide(BigInteger.valueOf(4));
				prime[2]=prime[2]+1;
			}
			while(true)
			{
				if(n.mod(BigInteger.valueOf(3))!=BigInteger.valueOf(0))
					break;
				n=n.divide(BigInteger.valueOf(3));
				prime[1]=prime[1]+1;
			}
			while(true)
			{
				if(n.mod(BigInteger.valueOf(2))!=BigInteger.valueOf(0))
					break;
				n=n.divide(BigInteger.valueOf(2));
				prime[0]=prime[0]+1;
			}
			if(n.compareTo(BigInteger.valueOf(1))>0)
				System.out.println("There is no such number.");
			else
			{
				for(i=0;i<8;i++)
				{
					while(prime[i]!=0)
					{
						prime[i]=prime[i]-1;
						if(i==0)
							System.out.print(2);
						if(i==1)
							System.out.print(3);
						if(i==2)
							System.out.print(4);
						if(i==3)
							System.out.print(5);
						if(i==4)
							System.out.print(6);
						if(i==5)
							System.out.print(7);
						if(i==6)
							System.out.print(8);
						if(i==7)
							System.out.print(9);
					}
				}
				System.out.println();
			}
		}
	}
}

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