P2480 古代猪文 题解

传送门

\(G^{\sum_{d|n}C_n^d}\bmod 999911659\)\(n,G\le 10^9\)

费马小定理:即求 \(G^{\sum_{d|n}C_n^d\bmod 999911658}\bmod 999911659\)

\(\sum_{d|n}C_n^d\bmod 999911658\),想用卢卡斯定理,但是模数不是质数。用 exLucas 就麻烦了。

观察一下,\(999911658=2\times 3\times 4679\times 35617\),这四个都是质数,可以求出 \(a_2=\sum_{d|n}C_n^d\bmod 2,a_3=\sum_{d|n}C_n^d\bmod 3,a_{4679}=\sum_{d|n}C_n^d\bmod 4679,a_{35617}=\sum_{d|n}C_n^d\bmod 35617.\)

所以可以用 CRT 解同余方程组 \(x\equiv a_i\pmod i\)\(x\) 就是 \(\sum_{d|n}C_n^d\bmod 999911658\)

posted @ 2024-03-08 19:15  FLY_lai  阅读(4)  评论(0编辑  收藏  举报