tle求调

P1593 因子和

ny_kuangbowen @ 2024-09-05 13:48:32

#include<bits/stdc++.h>
using namespace std;
unordered_map<int,int> ma;
const long long N=9901;
void divide(int x,int y){
    for(int i=2;i<=x/i;i++){
        while(x%i==0){
            x/=i;
            ma[i]++;
        }
        ma[i]*=y;
    }
    if (x>1){
        ma[x]+=y;
    }
}
signed main(){
    int n,c;
    cin >> c>>n;
    divide(c,n);
    int ans=1;
    for(auto it:ma){
        long long b=it.second,p=it.first,sum=1;
        while(b--){
            sum=(sum*p+1)%N;
        }
        ans*=sum;
        ans%=N;
    }
    cout<<ans;
    return 0;
}

|