题解 | #【模板】快速幂Ⅰ ‖ 整数#

【模板】快速幂Ⅰ ‖ 整数

https://www.nowcoder.com/practice/3d624107a6904da1bd0e8c9c85e17167

t = int(input())
def qpow(x,y,mod):
    res = 1
    while y:
        if y & 1:
            res *= x
            res %= mod
        x *= x
        x %= mod
        y >>= 1
    return res % mod

for _ in range(t):
    x,y,p = map(int,input().split())
    print(qpow(x,y,p))

全部评论

相关推荐

10-29 15:51
嘉应学院 Java
后端转测开第一人:你把简历的学历改成北京交通大学 去海投1000份发现基本还是没面试
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务