Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
prime factorization trial division
#include<bits/stdc++.h> #define LL long long #define MAXN 1000000000 using namespace std; inline void speed(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } vector <bool> isprime(MAXN,1); vector <int> primes; inline void pre(){ for(int i=2;i*i<MAXN;i++){ if(isprime[i]){ primes.push_back(i); for(int j=i*i;j<MAXN;j+=i){ isprime[j]=0; } } } for(int i=2;i<MAXN;i++){ if(isprime[i]){ primes.push_back(i); } } } int main() { speed(); pre(); LL n; //cin>>n; //for(int i=0;i<100;i++)cout<<primes[i]<<" "; /*while ( n != 0 ) { for(int i=0;i<primes.size();i++){ int pw=0; //cout<<n<<" "<<primes[i]<<endl; while(n%primes[i]==0){ if(n==1)break; //cout<<n<<" "<<primes[i]<<endl; n=n/primes[i]; pw++; } if(pw>0){ cout<<primes[i]<<"^"<<pw<<" "; } if(n==1){ break; } } if(n!=1){ cout<<n<<"^"<<1; } cout<<"\n"; cin>>n; }*/ return 0; }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
BLREDSET
Triangle
void sun()
looping with pointer
Dar
List add v2
std_minmax_unexpected_behaviour.cpp
CPP - Arrays - Ex.3
¡Arriba, Papalotes, Arriba! v2
multiply_without_asterisk
Please log in to post a comment.