?? pku2635.java
字號:
import java.io.*;
import java.util.*;
import java.math.BigInteger;
class Main
{
public static void main(String args[]) throws Exception
{
Scanner cin=new Scanner(System.in);
BigInteger bi;
String s;
int i, t;
while (cin.hasNext())
{
s = cin.next();
t = cin.nextInt();
if (t == 0)
{
break;
}
bi = new BigInteger(s);
if (bi.mod(BigInteger.valueOf(2)).equals(BigInteger.ZERO))
{
if (t > 2)
System.out.println("BAD 2");
else
System.out.println("GOOD");
continue;
}
if (bi.mod(BigInteger.valueOf(3)).equals(BigInteger.ZERO))
{
if (t > 3)
System.out.println("BAD 3");
else
System.out.println("GOOD");
continue;
}
if (bi.mod(BigInteger.valueOf(5)).equals(BigInteger.ZERO))
{
if (t > 5)
System.out.println("BAD 5");
else
System.out.println("GOOD");
continue;
}
for (i = 5; i < t; i+=2)
{
if (i % 3 == 0 || i % 5 == 0)
{
continue;
}
if (bi.mod(BigInteger.valueOf(i)).equals(BigInteger.ZERO))
{
System.out.println("BAD " + i);
break;
}
}
if (i >= t)
{
System.out.println("GOOD");
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -