题目意思:给你一个整数a和整数b 然后你需要求出存在多少个c*d=a (c!=d) min(c,d)>=b的组合数量 输出个数就好了。
如果直接循环遍历的话会超时。
然后就是利用唯一分解定理。
筛素数表
之前想说找出大于b的最小a因子 感觉除了搜索的话,然后使用(i+1)直接算 在分解的时候实现麻烦。
然后就是 算出总的因子数/2,然后减去小于b的。
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll maxn=1e6+5;
ll predictprimenum(ll x)
{
return (ll)(x/log(x));
}
int prime[maxn],status[maxn];
int len;
void pri()
{
len=0;
memset(status,0,sizeof(status));
for(int i=2; i<=maxn; i++)
{
if(!status[i])
{
prime[len++]=i;
for(int j=i; j<=maxn; j+=i) status[j]=1;
}
}
}
int main()
{
pri();
int t;
scanf("%d",&t);
for(int k=1; k<=t; k++)
{
ll a,b,en;
scanf("%lld%lld",&a,&b);
en=sqrt(a);
int ans=1;
ll c,num1=a;
if(b*b>a) ans=0;
else
{
for(int j=0; num1>1&&j<len; j++)
{
int i=0;
while(num1%prime[j]==0)
{
i++;
num1/=prime[j];
}
ans*=(i+1);
}
if(num1>1) ans*=2;///a本身为质数 超越了素数表里面的额数
///且只能有一个 假若有两个的话 值就会超过1E12
ans>>=1;
for(int j=1;j<b;j++)
if(a%j==0) ans--;
}
printf("Case %d: %d\n",k,ans);
}
return 0;
}