快速幂算法,取模
作者:互联网
1/4对998244353取模后为748683265
(1/a)%p=a**(p-2)%p
def ad(a, b, c):
d = 1
while(b):
if b%2 == 1:
d = (d*a)%c #(a*b)%c=((a%c)*(b%c))%c
a = (a*a)%c
b = b//2
return d
p = 998244353
print(ad(4, p-2, p))
#等价于
#print(4**(p-2)%p)
748683265
标签:取模,ad,b%,748683265,算法,print,快速,998244353 来源: https://blog.csdn.net/weixin_46287157/article/details/119282349