标签:set int 函数 ble div false i++ als ==
同时得到欧拉函数和素数表
const int maxn=10000000+5; bool check[maxn]; int phi[maxn]; int prime[maxn]; int tot; void phi_ans_prime_table(int n){ memset(check,false,sizeof(check)); phi[1]=1; tot=0; for(int i=2;i<=n;i++){ if(!check[i]){ prime[tot++]=i; phi[i]=i-1; } for(int j=0;j<tot;j++){ if(i*prime[j]>n) break; check[i*prime[j]]=true; if(i%prime[j]==0) { phi[i*prime[j]]=phi[i]*prime[j]; break; }else phi[i*prime[j]]=phi[i]*(prime[j]-1); } } }
标签:set int 函数 ble div false i++ als ==
原文地址:https://www.cnblogs.com/033000-/p/10088626.html