Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define mx 1000005
- using namespace std;
- vector<long long>prime;
- bool check[mx];
- void sieve()
- {
- long long sz,i,j;
- prime.push_back(2);
- for(i=3; i<mx; i+=2)
- {
- if(check[i]==false)
- {
- check[i] = true;
- prime.push_back(i);
- for(j=i*i; j<mx; j+=i+i)
- {
- check[j] = true;
- }
- }
- }
- }
- int main()
- {
- sieve();
- long long n,i,j,len;
- while(scanf("%lld",&n)==1)
- {
- if(n<0)
- break;
- bool tag = false;
- if(n!=1)
- {
- len = prime.size();
- for(i=0; i<len; i++)
- {
- if(n%prime[i]==0)
- {
- while(n%prime[i]==0)
- {
- tag = true;
- n/=prime[i];
- printf(" %lld\n",prime[i]);
- }
- }
- }
- }
- if(n!=1)
- {
- printf(" %lld\n",n);
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment