传送门:点击打开链接
分析:运用质数唯一分解定理求解
首先等式可以变化为 n(x+y) = xy 也就是 n^2 = (n-x)(n-y)
对n^2质数分解也就是对n质数分解
具体实现见代码:
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 70;
int a[maxn],tot;
int ans,n;
int main(){
int T;
scanf("%d",&T);
while (T--) {
scanf("%d",&n);
tot = 0;
memset(a,0,sizeof(a));
for (int i=2; i*i<=n; i++) if (n%i==0) {
while (n%i==0) a[tot]++, n/=i;
tot++;
}
if (n>1) a[tot++]++;
for (int i=0; i<tot; i++) a[i]<<=1; //左移相当于乘2,因为前面是对n分解,实际是要对n^2分解
ans = 1;
for (int i=0; i<tot; i++) ans *= (a[i]+1); // 加1是吧零次幂情况考虑进去
printf("%d\n",(ans+1)/2); // 除以2是因为题目要求x<=y
}
return 0;
}