一道唯一分解的题目。
代码:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
#define maxn 10000010
typedef long long LL;
LL prime[1000000];
bool p[maxn];
int k;
void find_prim()
{
k = 0;
for(LL i = 2; i <= maxn; i++)
{
if(!p[i])
{
prime[k++] = i;
for(LL j = i+i; j <= maxn; j+=i)
{
p[j] = 1;
}
}
}
}
int main()
{
find_prim();
int t, kase = 1; cin >> t;
LL n;
while(t--)
{
scanf("%lld", &n);
LL ans = 1;
for(int i = 0; i < k && (LL)prime[i]*prime[i] <= n; i++)
{
if(n%prime[i] == 0)
{
int cnt = 0;
while(n%prime[i] == 0)
{
cnt++;
n /= prime[i];
}
ans *= (2*cnt + 1);
}
}
if(n > 1) ans *= 3;
ans = ans/2 + 1;
printf("Case %d: %lld\n", kase++, ans);
}
return 0;
}