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
}
相关推荐
microrain1 小时前
设备说 128.7,平台存了 100
物联网·golang·物模型·sagooiot
Navigator_Z2 小时前
LeetCode //C - 1331. Rank Transform of an Array
c语言·算法·leetcode
Tisfy3 小时前
LeetCode 1202.交换字符串中的元素:分组排序(连通图)
算法·leetcode·字符串·bfs·题解·排序·连通图
利威尔xu11 小时前
Go map 并发十连问:多 goroutine 同时读写触发 fatal error,进程直接崩溃
开发语言·golang
喵了几个咪18 小时前
GoWind Admin 拆解:智能问数——从一句自然语言到一张可信图表
ai·golang·llm·智能问数·gowind
catchadmin19 小时前
Laravel Go 高性能全栈框架发布
golang·php·laravel
小白的高手之路19 小时前
【LeetCode 热题 100】206. 反转链表|链表、迭代、递归(Python)
笔记·python·算法·leetcode·链表·职场和发展·力扣
16月6日-晴20 小时前
122. 买卖股票的最佳时机 II【贪心】
算法·leetcode
我不会起名字32221 小时前
Go 泛型与反射边界:编译膨胀、接口装箱与热路径的 4 个取舍
golang·go·反射·泛型·后端架构
小白的高手之路1 天前
【【LeetCode 热题 100】160. 相交链表|链表、哈希表、双指针(Python)
python·算法·leetcode·链表·力扣·散列表