给出n,求有几对lcm(i,j)=n(i<=n,j<=n,i<=j)
lcm(i,j)=max(ei,ej)…
了解了通过分解质因数,求两个小于某个值的数的lcm
const int N = 1e7 + 5;//最多有一个大于sqrt(n)的质因子 所以素数表开到1e7
int t;
int tot, p[N/10];//N越大 1—N中质数小于N/10
bool fg[N];
void x_x(int n)
{
f(i, 2, n)
{
if (!fg[i])p[tot++] = i;
for (int j = 0;p[j] <= n / i;++j)
{
fg[p[j] * i] = true;
if (i%p[j] == 0)break;
}
}
}
int main()//给出n,求有几对满足lcm(i,j)==n 考虑分解成N的质因数形式
{
cin >> t;
ll n;
int cnt = 0;
x_x(N - 1);
while (t--)
{
cin >> n;
ll ans = 1;
for (int i = 0;i < tot &&(ll)p[i] * p[i] <= n;i++)//tle了就预处理打个素数表
{
if (n % p[i] == 0)
{
ll cot = 0;
while (n%p[i] == 0)
{
n /= p[i];
cot++;
}
ans *= 2*(cot + 1) - 1;//
}
}
if (n > 1)ans *= 2 * (1 + 1) - 1;//最多一个大于n/i
printf("Case %d: %lld\n", ++cnt, ans/2+1);
}
return 0;
}