标签:eve get bre cpp 质因数 class code for max
const int MAXN = 1e7;
int p[MAXN + 5], ptop;
bool pn[MAXN + 5];
void sieve() {
int n = MAXN;
pn[1] = 1;
for(int i = 2; i <= n; i++) {
if(!pn[i])
p[++ptop] = i;
for(int j = 1; j <= ptop; j++) {
int t = i * p[j];
if(t > n)
break;
pn[t] = 1;
if(i % p[j] == 0)
break;
}
}
printf("ptop=%d\n", ptop);
/*for(int i = 1; i <= ptop; ++i)
printf("%d:%d\n", i, p[i]);*/
}
int fac[105][2], ftop;
void get_fac(int n) {
ftop = 0;
for(int i = 1; i <= ptop; ++i) {
if(n % p[i] == 0) {
fac[++ftop][0] = p[i];
fac[ftop][1] = 0;
while(n % p[i] == 0) {
n /= p[i];
++fac[ftop][1];
}
}
}
if(n > 1) {
fac[++ftop][0] = n;
fac[ftop][1] = 1;
}
}
标签:eve get bre cpp 质因数 class code for max
原文地址:https://www.cnblogs.com/KisekiPurin2019/p/12228397.html