Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define L(i, m, n) for(int i(m);i < n;i++)
- #define _(n) L(i,0,n)
- #define __(n) L(i,1,n)
- #define pb push_back
- #define D(X) cout<<" "<<#X": "<<X<<endl;
- #define in(x) cin >> x
- #define SZ(a) (int)a.size()
- #define ff first
- #define ss second
- #define RF(X) freopen(X, "r", stdin)
- #define WF(X) freopen(X, "w", stdout)
- using namespace std;
- typedef long long ll;
- typedef pair<ll,ll> pll;
- typedef vector<int> vi;
- typedef vector<ll> vll;
- typedef pair<int,int> pii;
- typedef vector<pii> vpii;
- typedef pair<int, string> pis;
- typedef vector<string> vs;
- typedef pair<pair<int, int>, pair<int, int > > piiii;
- typedef map<int,int> mpii;
- const int maxn=1e5+5;
- bitset <maxn> bs;
- int P[maxn];
- void sieve(int n){
- /**if you want have list of primes use the second loop only plz**/
- bs[0]=bs[1]=1,P[1]=1;
- 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;
- for(int i = 2;i <= n;i++) if(!bs[i])P[i]=i;
- }
- void F(int N){
- // this function holds the prime factors in vector a depending on sieve()
- set<int> a;
- while(P[N]!=N)
- a.insert(P[N]),N/=P[N];
- if(N)a.insert(N);
- for(set<int>::iterator it=a.begin();it!=a.end();it++)printf(" %d",*it);printf("\n");
- }
- int main(){
- // WF("out.txt");
- sieve(maxn);
- for(int i=2;i<=1e5;i++){
- printf("%d:",i);F(i);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement