技术栈

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

m0_571957582024-08-25 10:25

题目:

题解:

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;
    }
}
上一篇:Morris遍历-二叉树遍历空间复杂度O(1)
下一篇:BMS和UPS
相关推荐
星晨雪海
1 天前
企业标准 DTO 传参 + Controller + Service + 拷贝工具类完整版
java·开发语言·python
pshdhx_albert
1 天前
AI agent实现打字机效果
java·http·ai编程
沉鱼.44
1 天前
第十二届题目
java·前端·算法
赫瑞
1 天前
数据结构中的排列组合 —— Java实现
java·开发语言·数据结构
周末也要写八哥
1 天前
多进程和多线程的特点和区别
java·开发语言·jvm
惜茶
1 天前
vue+SpringBoot(前后端交互)
java·vue.js·spring boot
杰克尼
1 天前
springCloud_day07(MQ高级)
java·spring·spring cloud
NHuan^_^
2 天前
SpringBoot3 整合 SpringAI 实现ai助手(记忆)
java·人工智能·spring boot
Mr_Xuhhh
2 天前
从ArrayList到LinkedList:理解链表,掌握Java集合的另一种选择
java·数据结构·链表
倦王
2 天前
力扣日刷47-补
python·算法·leetcode
热门推荐
01GitHub 镜像站点02一周AI热点速览(2026.03.31-04.06):GPT-6曝光、谷歌开源Gemma 4、资本狂飙与模型军备竞赛03OpenClaw 请求超时 llm request timed out 怎么解决?3 种方案实测,附完整排查流程04AI 编程效率翻倍:Superpowers Skills 上手清单 + 完整指南05VMware Workstation Pro 17 虚拟机完整安装教程(2026最新)06Qwen3.5-Omni与Qwen3.6模型全面解析(含测评/案例/使用教程)07Oh My Codex 快速使用指南08UV安装并设置国内源09Claude Code 未登录 使用第三方模型10实测!Gemma 4 成功跑在安卓手机上:离线 AI 助手终于来了