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
}
相关推荐
好易学·数据结构23 分钟前
可视化图解算法75:最长上升子序列(最长递增子序列)
数据结构·算法·leetcode·动态规划·力扣·牛客网
Jeremy爱编码23 分钟前
leetcode热题岛屿数量
算法·leetcode·职场和发展
源代码•宸44 分钟前
goframe框架签到系统项目开发(用户认证、基于 JWT 实现认证、携带access token获取用户信息)
服务器·开发语言·网络·分布式·后端·golang·jwt
思成Codes1 小时前
Gin路由:构建高效RESTful API
golang·restful·xcode·gin
Clarence Liu1 小时前
Go Map进化史:从桶链式哈希表到Swiss Table的源码级剖析
golang·哈希算法·散列表
koping_wu1 小时前
【leetcode】排序数组:快速排序、堆排序、归并排序
java·算法·leetcode
历程里程碑1 小时前
LeetCode 283:原地移动零的优雅解法
java·c语言·开发语言·数据结构·c++·算法·leetcode
卜锦元1 小时前
Golang后端性能优化手册(第一章:数据库性能优化)
大数据·开发语言·数据库·人工智能·后端·性能优化·golang
元亓亓亓1 小时前
LeetCode热题100--139. 单词拆分--中等
算法·leetcode·职场和发展
小高Baby@1 小时前
map的数据结构,扩容机制,key是无序的原因
数据结构·golang·哈希算法