別の BigInteger の問題。私のコードは int と long で機能しますが、UVa のテスト ケースは大きいため、BigInteger を使用する必要があります。しかし、BigInteger の使い方がわからず、気が狂ってしまいます! コードは for ループにも入りません。コンディション部分に引っかかっているようです。for または while を使用してみましたが、同じ問題があります。
public class Main{
public static void main(String[] asdf){
Scanner pp = new Scanner(System.in);
int testCases = pp.nextInt();
while(testCases-- > 0){
//BigInteger a = pp.nextBigInteger();
BigInteger low = pp.nextBigInteger();
BigInteger upp = pp.nextBigInteger();
BigInteger max = BigInteger.ZERO;
BigInteger i = low;
//((i.compareTo(upp)==-1)||
//(i.compareTo(upp)==0));
//i.add(BigInteger.ONE))
while((i.compareTo(upp))<0){
if(divCount(i).compareTo(divCount(max))==1){
max = i;
}
i.add(BigInteger.ONE);
}
System.out.println("Between "+low+" and "+upp+", "+max+" has a maximum of "+divCount(max)+" divisors.");
}
}
public static BigInteger divCount(BigInteger n){
BigInteger lim = n;
BigInteger size = BigInteger.ZERO;
BigInteger i = BigInteger.ONE;
while(i.compareTo(lim)<0){
if((n.mod(i).compareTo(BigInteger.ZERO))==0){
lim = n.divide(i);
if(!(lim.equals(i))){
size.add(BigInteger.ONE);
}
size.add(BigInteger.ONE);
}
i.add(BigInteger.ONE);
}
//return size;
return BigInteger.ONE;
}
}