40分求助
  • 板块P1593 因子和
  • 楼主Gao_l
  • 当前回复6
  • 已保存回复6
  • 发布时间2023/7/20 21:40
  • 上次更新2023/11/3 08:33:32
查看原帖
40分求助
750728
Gao_l楼主2023/7/20 21:40
#include<bits/stdc++.h>
using namespace std;
const int mod=9901;
int a,b,sa,n[10005][2],cot=0,ans=1;
int pw(int ml,int nl){
    int s=1;
    while(nl){
        if(nl%2==1){
            s=(s%mod)*(ml%mod)%mod;
        }
        ml=ml*ml%mod;
        nl=nl>>1;
    }
    return s%mod;
}
int sum(int x,int y){
    int k=0;
    y*=b;
    if(x%mod==1){
        k=(y+1)%mod;
    }else{
        k=(pw(x%mod,y+1)-1)%mod*pw((x-1)%mod,mod-2)%mod;
    }
    return k%mod;
}

int main(){
    cin >> a >> b;
    if(!a){
        cout << "0";
        return 0;
    }
    for(int i=2;i*i<=a;i++){
        if(!a%i){
            cot++;
            n[cot][0]=i;
            n[cot][1]=1;
            a/=i;
            while(a%i==0){
			    n[cot][1]++;
		    	a=a/i;
		    }
        }
    }
    if(a!=1){
        cot++;
        n[cot][0]=a;
        n[cot][1]=1;
    }
    for(int i=1;i<=cot;i++){
        ans=ans*sum(n[i][0],n[i][1])%mod;
    }
    cout << (ans%mod+mod)%mod;
}
2023/7/20 21:40
加载中...