Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
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
Kalkulator z bajerami
aa
cppPyProperty
Grundy Number
primes
xyp
strict aliasing
c++ car racing game
PointPattern
BST to DLL