终于数学还是咱来学,想想tls当年刷的效率。。自己还是要加油
//#pragma comment(linker, "/STACK:1024000000,1024000000") #include<bits/stdc++.h> #include<stdio.h> #include<algorithm> #include<queue> #include<string.h> #include<iostream> #include<math.h> #include<set> #include<map> #include<vector> #include<iomanip> using namespace std; #define ll long long #define pb push_back #define FOR(a) for(int i=1;i<=a;i++) const double PI = acos(-1.0); const int maxn=1e6+7; const int mod=998244353; int prime[maxn+1]; void getprime(){ memset(prime,0,sizeof prime); for(int i=2;i<=maxn;i++){ if(!prime[i])prime[++prime[0]]=i; for(int j=1;j<=prime[0] && prime[j]<=maxn/i;j++){ prime[prime[j]*i]=1; if(i%prime[j]==0)break; } } } ll factor[100][2]; int fatcnt; int getFactors(ll x){ fatcnt=0; ll tmp=x; int ret=1; for(int i=1;prime[i]<=tmp/prime[i];i++){ factor[fatcnt][1]=0; if(tmp%prime[i]==0){ factor[fatcnt][0]=prime[i]; while(tmp%prime[i]==0){ factor[fatcnt][1]++; tmp/=prime[i]; } //fatcnt++; ret*=(factor[fatcnt][1]+1); } } if(tmp!=1){ //factor[fatcnt][0]=tmp; //factor[fatcnt++][1]=1; ret*=2; } ret/=2;//毯子算同一种 //return fatcnt return ret; } void solve(ll a,ll b,int t){ if(a/b<b){ printf("Case %d: 0 ",t);return; } int ans=getFactors(a); for(ll i=1;i<b;i++){ if(a%i==0)ans--; } printf("Case %d: %d ",t,ans); } int main(){ int T;scanf("%d",&T); int t=0; getprime(); while(t!=T){ t++; ll a,b; scanf("%lld%lld",&a,&b); solve(a,b,t); } }