2022.07.26笔记

· · 个人记录

2022.07.26 笔记

for (unordered_map<int, int>::iterator it = mp.begin(); it != mp.end(); it ++ )
{
    int t = 1;
    int p = it -> first;
    int c = it -> second;
    while (c -- )
    {
        t = (p *t + 1) % mod;
        /*t = 1 
        t = p + 1 
        t = p(p + 1) + 1 = p ^ 2 + p + 1 
        t = p(p ^ 2 + p + 1) + 1 = p ^ 3 + p ^ 2 + p ^ 1 + 1 */
    }
    ans = ans * t % mod;
}

最大公因数

int gcd(int a, int b)
{
    return b ? gcd(d, a % b) : a;
}