| ||||||||||
| 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的 为什么会runtime error啊import java.util.*;
import java.io.*;
import java.math.*;
public class RoundandRoundWeGo
{
public static void main(String[] args) throws Exception
{
BufferedReader sr=new BufferedReader(new InputStreamReader(System.in));
String line;
while(true)
{
line=sr.readLine();
BigInteger input=new BigInteger(line);
BigInteger output;
String b;
int length=line.length();
int tag=1;
if(input.compareTo(new BigInteger("0"))!=0)
{
for(int i=1;i<=length;i++)
{
output=input.multiply(new BigInteger(Integer.toString(i)));
b=output.toString();
if(!judge(line,b)) tag=0;
}
if(tag==0) System.out.println(line+" is not cyclic");
else System.out.println(line+" is cyclic");
}
else
System.out.println(line+" is cyclic");
}
}
public static boolean judge(String a,String b)
{
int length=b.length();
if(a.length()==length)
{
String sub;
int i;
for(i=0;i<length;i++)
{
sub=b.substring(i);
if(a.startsWith(sub)) break;
}
if(i==length)
return false;
else
{
String asub=a.substring((length-i));
String bsub=b.substring(0, i);
if(asub.equals(bsub)) return true;
else return false;
}
}
else
return false;
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator