质因数分解

#include <bits/stdc++.h>
using namespace std;

void solve(){
    int n;
    cin>>n;
    map<int,int> prifac;
    for(int i=2;i<=n;i++){
        int x=36;
        for(int j=2;j<=x/j;j++){   //质因数分解
            while(x%j==0){
                prifac[j]++;
                x/=j;
            }
        }
        if(x>1) prifac[x]++;
    }
    for(auto p:prifac){
        cout<<p.first<<" "<<p.second<<"\n";   //n!==p1.first^p1.second*p2.first^p2.secnod......pn.first^pn.second
    }
}

int main() {
    ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
    solve();
    return 0;
}

 

posted @ 2023-11-23 13:10  osir  阅读(0)  评论(0编辑  收藏  举报