Prime Factorization Algorithm

Правка en1, от ruhan.habib39, 2015-10-25 15:53:57

What's the name of the following algorithm:

const int MAXN = 100*1000;
unordered_map<int,int> factors[MAXN+10];
vector<bool> isprime(MAXN+10, true);
int primeFactor[MAXN+10];

void init() {
   isprime[0] = isprime[1] = false;
   for(int i = 2; i*i <= MAXN; i++) {
     if(isprime[i]) {
       for(int j = i*i; j <= MAXM; j += i) {
          isprime[j] = false;
          primeFactor[j] = i;
       }
     }
   }
   for(int i = 2; i <= MAXM; i++) {
     if(isprime[i]) factors[i][i] = 1;
     else {
       int dv = primeFactor[i];
       factors[i] = factors[i/dv];
       factors[i][dv]++;
     }
   }
}
Теги factorisation, prime-factorisation, algorithm, name

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский ruhan.habib39 2015-10-25 15:53:57 677 Initial revision (published)