P1593 88pts求助
  • 板块学术版
  • 楼主WD2c0mP
  • 当前回复2
  • 已保存回复2
  • 发布时间2022/12/27 15:39
  • 上次更新2023/10/24 06:25:20
查看原帖
P1593 88pts求助
780641
WD2c0mP楼主2022/12/27 15:39

P1593 88pts求助

#include<bits/stdc++.h>
using namespace std;
int shike[100010],cn[100010]; 
const long long mod = 9901;
inline long long ksm(long long a,long long b){
    long long ans = 1;
    while (b){
        if (b & 1) 
            ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}
inline long long ny(long long x){
    return ksm(x,mod - 2) % mod;
}
int main(){
    int a,b;
    scanf("%d %d",&a,&b); 
    while(a % 9901 == 0) a /= 9901;
    int pswqq = 0;
    for (int i = 2;i * i <= a;i ++){
        if (a % i == 0){
            shike[++pswqq] = i;
            while (a % i == 0){
                a /= i;
                cn[pswqq] ++;
            }
        }
    }
    if (a > 1){
        shike[++pswqq] = a;
        cn[pswqq] = 1;
    } 
    long long sum = 1;
    for (int i = 1;i <= pswqq;i ++){
        /*
        shike[i] ^ (cn[i] * b + 1) - 1 / shike[i] - 1 
        */ 
        long long d = cn[i] * b + 1,f = shike[i];
        sum *= (ksm(f,d) % mod - 1) % mod * ny(f - 1) % mod;
        sum %= mod; 
    } 
    printf("%lld\n",sum % mod);
    return 0;
} 
2022/12/27 15:39
加载中...