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

题目:

题解:

java 复制代码
class Solution {
    static final int MOD = 1337;

    public int superPow(int a, int[] b) {
        int ans = 1;
        for (int e : b) {
            ans = (int) ((long) pow(ans, 10) * pow(a, e) % MOD);
        }
        return ans;
    }

    public int pow(int x, int n) {
        int res = 1;
        while (n != 0) {
            if (n % 2 != 0) {
                res = (int) ((long) res * x % MOD);
            }
            x = (int) ((long) x * x % MOD);
            n /= 2;
        }
        return res;
    }
}
相关推荐
草莓熊Lotso8 分钟前
Git 本地操作进阶:版本回退、撤销修改与文件删除全攻略
java·javascript·c++·人工智能·git·python·网络协议
Ka1Yan10 分钟前
[数组] - LeetCode 704. 二分查找
java·开发语言·算法·leetcode·职场和发展
2501_9418814015 分钟前
区块链技术:颠覆金融与未来社会的力量
leetcode
合作小小程序员小小店20 分钟前
web网页开发,在线%餐饮点餐%系统,基于Idea,html,css,jQuery,java,ssm,mysql。
java·前端·数据库·html·intellij-idea·springboot
SimonKing23 分钟前
IntelliJ IDEA 2025.2.x的小惊喜和小BUG
java·后端·程序员
曾帅16829 分钟前
idea springboot开发编译所见即所得应用不需要重启
java·spring boot·intellij-idea
q***01771 小时前
Spring Boot 热部署
java·spring boot·后端
Seven971 小时前
SpringCloud 常见面试题(三)
java
H***99761 小时前
Java虚拟现实案例
java·开发语言·vr