94分求助!!!
  • 板块P1593 因子和
  • 楼主Enoch2013
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/7/6 10:33
  • 上次更新2024/7/6 12:10:04
查看原帖
94分求助!!!
1069719
Enoch2013楼主2024/7/6 10:33

我不明白为什么WA了#14


代码:

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int M = 9901;
LL a, b;
map<LL, LL> m;
void fun(LL n)
{
    for (int i = 2; i <= sqrt(n); i++)
        while (n % i == 0)
        {
            m[i]++;
            n /= i;
        }
    if (n > 1)
        m[n]++;
}
LL f(LL a, LL b)
{
    LL ans = 1;
    while (b)
    {
        if (b % 2 == 1)
            ans = ans * a % M;
        a = a * a % M;
        b /= 2;
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> a >> b;
    fun(a);
    LL ans = 1;
    for (map<LL, LL>::iterator it = m.begin(); it != m.end(); it++)
    {
        LL p = it->first, c = it->second;
        c *= b;
        if ((p - 1) % M != 0)
        {
            LL x = f(p, c + 1) - 1, y = f(p - 1, M - 2);
            ans = ans * x % M * y % M;
        }
        else
            ans = ans * (c + 1) % M;
    }
    cout << ans;
    return 0;
}
2024/7/6 10:33
加载中...