- 约数,倍数,质因数等都应该联想素因子分解。
- 要考虑哪些情况应该排除,哪些不应该排除,细节的处理。
- 这道题当一对数相等时不判重,而只有一对这样的数,就是(n,n)。
题目链接:http://acm.hust.edu.cn/vjudge/problem/26946
#pragma comment(linker,"/STACK:1024000000,1024000000")
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cstdlib>
#include<cmath>
#include<cctype>
#include<string>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<ctime>
#include<vector>
#include<fstream>
#include<list>
using namespace std;
#define ms(s) memset(s,0,sizeof(s))
typedef unsigned long long ULL;
typedef long long LL;
const int INF = 0x3fffffff;
const int N = 10000000;
bool primeTable[N+5];
int p[N/10],tot;
int e[N/10];
LL ans;
void make_primeTable(){
tot = 0;
fill(primeTable,primeTable+N,1);
primeTable[0] = false;
primeTable[1] = false;
int maxed = sqrt(N);
for(int i = 2; i <= maxed; ++i){
if(primeTable[i] == true){
p[tot++] = i;
for(int j = i*i; j <= N; j += i)
primeTable[j] = false;
}
}
for(int i = maxed+1; i <= N; ++i)
if(primeTable[i] == true) p[tot++] = i;
}
void add_factor(LL n){
memset(e,0,sizeof(e));
ans = 1;
if(n < 2) return;
for(int i = 0; i < tot; ++i){
while(n%p[i] == 0){
e[i]++;
n /= p[i];
}
ans *= 2*e[i]+1;
if(n == 1LL) break;
}
if(n > 1LL){
ans *= 3;
}
ans = (ans+1)/2;
}
int main()
{
// freopen("F:\\input.txt","r",stdin);
// freopen("F:\\output.txt","w",stdout);
// ios::sync_with_stdio(false);
make_primeTable();
int t;
LL n;
scanf("%d",&t);
for(int cas = 1; cas <= t; ++cas){
scanf("%lld",&n);
add_factor(n);
printf("Case %d: %lld\n",cas,ans);
}
return 0;
}