Criba de Erastotenes
Enviado por sidful_lsa • 14 de Febrero de 2019 • Práctica o problema • 630 Palabras (3 Páginas) • 184 Visitas
#include
#include
#include
using namespace std;
typedef long long i64;
vector
vector
int raiz = sqrt(n);
vector
for (int i = 4; i <= n; i += 2)
criba[i] = 2;
for (int i = 3; i <= raiz; i += 2)
if (!criba[i])
for (int j = i * i; j <= n; j += i){
if (!criba[j]) criba[j] = i;}
return criba;
}
vector
vector
i64 i=n;
while(1){
if(criba[i] == i ){
factores.push_back(i);
break;
}
factores.push_back(criba[i]);
i = (i)/(criba[i]);
//cout<<"i:"<
}
return factores;
}
int main(){
criba = Criba(150000);
vector
for( int i = 0; i < 1000; i++ ){
if( criba[i] == 0 ){
primos.push_back( i );
criba[i]=i;}
}
//for( int i = 2; i < primos.size(); i++ )
// cout << primos[i] << endl;
vector
for( int i = 0; i < fact.size() ; i++ ){
cout<
}cout<<"\n";
return 0;
}
...