poj 1811 Prime Test
一直RE, 据说是爆栈啦。。。。
import java.math.BigInteger;
import java.util.Scanner;
public class prime {
public static void main(String args[]) {
int n, flag = 0, i;
BigInteger a, b, t, c, v;
Scanner cin = new Scanner(System.in);
b = BigInteger.valueOf(2);
n = cin.nextInt();
for (i = 0; i < n; i++) {
t = cin.nextBigInteger();
if (t.isProbablePrime(1000))
System.out.println("Prime");
else {
for (;;) {
c = t.mod(b);
if (c.compareTo(BigInteger.ZERO) == 0) {
System.out.println(b);
break;
} else
b = b.nextProbablePrime();
}
}
}
}
}
posted on 2011-08-14 09:15 more think, more gains 阅读(169) 评论(0) 编辑 收藏 举报