Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.35 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define L(i, m, n) for(int i(m);i < n;i++)
  3. #define _(n) L(i,0,n)
  4. #define __(n) L(i,1,n)
  5. #define pb push_back
  6. #define D(X) cout<<"  "<<#X": "<<X<<endl;
  7. #define in(x) cin >> x
  8. #define SZ(a) (int)a.size()
  9. #define ff first
  10. #define ss second
  11. #define RF(X) freopen(X, "r", stdin)
  12. #define WF(X) freopen(X, "w", stdout)
  13. using namespace std;
  14. typedef long long ll;
  15. typedef pair<ll,ll> pll;
  16. typedef vector<int> vi;
  17. typedef vector<ll> vll;
  18. typedef pair<int,int> pii;
  19. typedef vector<pii> vpii;
  20. typedef pair<int, string> pis;
  21. typedef vector<string> vs;
  22. typedef pair<pair<int, int>, pair<int, int > > piiii;
  23. typedef map<int,int> mpii;
  24. const int maxn=1e5+5;
  25. bitset <maxn> bs;
  26. int P[maxn];
  27. void sieve(int n){
  28.     /**if you want have list of primes use the second loop only plz**/
  29.    bs[0]=bs[1]=1,P[1]=1;
  30.    for(int i = 2;i*i<=n;i++) if(!bs[i])for(int j = i*i;j <= n;j+=i) bs[j]=1,P[j]=i;
  31.    for(int i = 2;i <= n;i++) if(!bs[i])P[i]=i;
  32. }
  33. void F(int N){
  34. //    this function holds the prime factors in vector a depending on sieve()
  35.     set<int> a;
  36.     while(P[N]!=N)
  37.         a.insert(P[N]),N/=P[N];
  38.     if(N)a.insert(N);
  39.     for(set<int>::iterator it=a.begin();it!=a.end();it++)printf(" %d",*it);printf("\n");
  40. }
  41. int main(){
  42. //    WF("out.txt");
  43.     sieve(maxn);
  44.     for(int i=2;i<=1e5;i++){
  45.         printf("%d:",i);F(i);
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement