刷水题练练手~~
数学问题,N=i*j+i+j可以转化为:N+1 = (i+1)*(j+1)
问题就转化成了求有多少个大于2的整数的积为N+1。注意i要小于等于j,所以只要试到到N+1的开方就可以了。
import java.util.Scanner;
public class Main {
public static void main(String...args){
T = cin.nextInt();
while(T-- != 0){
N = cin.nextLong();
count = 0;
double sqrt = Math.sqrt((N+1));
for(int i = 2; i <= sqrt; i++){
if((N+1)% i == 0) count++;
}
System.out.println(count);
}
}
static Scanner cin = new Scanner(System.in);
static int T, count;
static long N;
}