题目大意:
s=a∗b
; 已知
s,amin
(最小的
a
)问有多少个这样的组合;
思路:
s=∏i=1kpeii;s
质数分解;
Ns的因子个数
,
=∑i=1k(1+ei)
;
num(a,b)=N2
;
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define N 1000010
#define LL long long
using namespace std;
bool not_prime[N];
int prim[100000];
int cnt = 0;
void init()
{
memset(not_prime, 0, sizeof(not_prime));
prim[1] = 0;
for(int i = 2; i < N; i++)
{
if(!not_prime[i])
{
prim[cnt++] = i;
for(int j = i + i; j < N; j += i)
{
not_prime[j] = 1;
}
}
}
// cout << cnt << ' ' << prim[cnt-1] << endl;
}
LL get(LL n)
{
LL ans = 1;
for (int i = 0; prim[i] * prim[i] <= n && i < cnt; i++)
{
if (n % prim[i] == 0)
{
int cnt = 0;
while (n % prim[i] == 0)
{
cnt++;
n /= prim[i];
}
ans *= (cnt + 1);
}
}
if (n > 1)
{
ans *= 2;
}
return ans;
}
int main()
{
init();
int T;
scanf("%d", &T);
for (int cas = 1; cas <= T; cas++)
{
LL n, m;
scanf("%lld%lld", &n, &m);
if (n <= m * m)
{
printf("Case %d: 0\n", cas);
continue;
}
LL ans = get(n) / 2;
for (int i = 1; i < m; i++)
{
if (n % i == 0)
{
ans--;
}
}
printf("Case %d: %lld\n", cas, ans);
}
return 0;
}