题意 :
一个数可以表示 N 对 数相乘(x1,x2)
输入另一个数b 求有多少对x1 x2 俊大于等于 b
求标准分解式的指数 因子数为 II(ai + 1)(表示不出数学符号.............)
代码:
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long LL;
const int maxn = 1e6 +131;
int vis[maxn];
LL Primes[maxn];
int Count,ans;
LL a,b;
void INT() { //质数表
Count = 0;
for(int i = 2; i <= maxn; ++i)
{
if(!vis[i]) {
Primes[Count++] = i;
for(int j = i; j <= maxn; j+= i)
vis[j] = 1;
}
}
}
void DFS(LL dep, LL x) { //构造解答树,求出小于b的有多少个a 的因数
ans--;
for(int i = dep; i < Count; ++i)
{
if(x * Primes[i] < b)
{
if( a % (x* Primes[i]) == 0)
DFS(i,x*Primes[i]);
}
else return ;
}
}
int main() {
INT();
int T;
scanf("%d",&T);
for(int kase = 1; kase <= T; ++kase) {
scanf("%lld%lld",&a,&b) ;
if(b*b >= a) {
printf("Case %d: 0\n",kase);
continue;
}
ans = 1;
LL tmp = a;
for(int i = 0; i < Count && Primes[i] * Primes[i] <= tmp; ++i ) {
if(tmp % Primes[i] == 0) {
LL tot = 0;
while(tmp % Primes[i] == 0) {
tot++;
tmp /= Primes[i];
}
ans *= (tot+1);
}
}
if(tmp > 1) ans <<= 1; //如果还有剩余的质数,则因子数还要 * 2
ans >>= 1;//求有多少对
DFS(0,1); if(b == 1) ans ++;
printf("Case %d: %lld\n",kase, ans);
}
return 0;
}