Golang | Leetcode Golang题解之第372题超级次方

题目:

题解:

Go 复制代码
const mod = 1337

func pow(x, n int) int {
    res := 1
    for ; n > 0; n /= 2 {
        if n&1 > 0 {
            res = res * x % mod
        }
        x = x * x % mod
    }
    return res
}

func superPow(a int, b []int) int {
    ans := 1
    for _, e := range b {
        ans = pow(ans, 10) * pow(a, e) % mod
    }
    return ans
}
相关推荐
We་ct8 小时前
LeetCode 148. 排序链表:归并排序详解
前端·数据结构·算法·leetcode·链表·typescript·排序算法
x_xbx10 小时前
LeetCode:2. 两数相加
算法·leetcode·职场和发展
_日拱一卒11 小时前
LeetCode:最长连续序列
算法·leetcode·职场和发展
重生之后端学习11 小时前
287. 寻找重复数
数据结构·算法·leetcode·深度优先·图论
fy1216312 小时前
GO 快速升级Go版本
开发语言·redis·golang
实心儿儿12 小时前
算法7:两个数组的交集
算法·leetcode·职场和发展
sheeta199813 小时前
LeetCode 每日一题笔记 日期:2025.03.19 题目:3212.统计X和Y频数相等的子矩阵数量
笔记·leetcode·矩阵
Storynone13 小时前
【Day28】LeetCode:509. 斐波那契数,70. 爬楼梯,746. 使用最小花费爬楼梯
python·算法·leetcode
博风14 小时前
算法:双指针解:盛最多水的容器
算法·leetcode
童话ing15 小时前
【Golang】Golang Map数据结构底层原理
数据结构·golang·哈希算法