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
}
相关推荐
ttwuai1 小时前
Cursor 生成 CRUD 后,Go 后台接口别只测 200:JWT、RBAC 和 tenant_id 怎么验
开发语言·后端·golang
闪电悠米8 小时前
力扣hot100-73.矩阵置零-标记数组详解
算法·leetcode·矩阵
microrain9 小时前
从硬编码到热插拔:SagooIoT插件架构如何打破物联网平台的扩展瓶颈
物联网·golang·开源·sagooiot
geovindu10 小时前
go:Backtracking Algorithm
开发语言·后端·算法·golang·回溯算法
qq_4523962310 小时前
第六篇:《并发编程核心:Goroutine 与 Channel》
golang
llwszx11 小时前
【Java/Go后端手撸原生Agent(第五篇):多工具并行调用 + BashTool执行引擎 + Judge证据链升级】
java·后端·golang·状态机·pydantic·agnet·llm-as-judge
FfHUCisI11 小时前
Go语言程序结构 —— 变量、声明与零值机制
golang
过期动态11 小时前
【LeetCode 热题 100】找到字符串中所有字母异位词
java·数据结构·算法·leetcode·职场和发展·rabbitmq
超人不会飞_Jay12 小时前
Go课程2
开发语言·后端·golang
Adios79420 小时前
设置交集大小至少为2
数据结构·算法·leetcode