C++ | Leetcode C++题解之第372题超级次方

题目:

题解:

cpp 复制代码
class Solution {
    const int MOD = 1337;

    int pow(int x, int n) {
        int res = 1;
        while (n) {
            if (n % 2) {
                res = (long) res * x % MOD;
            }
            x = (long) x * x % MOD;
            n /= 2;
        }
        return res;
    }

public:
    int superPow(int a, vector<int> &b) {
        int ans = 1;
        for (int e: b) {
            ans = (long) pow(ans, 10) * pow(a, e) % MOD;
        }
        return ans;
    }
};
相关推荐
阿让啊3 小时前
C语言strtol 函数使用方法
c语言·数据结构·c++·单片机·嵌入式硬件
liulilittle3 小时前
OPENPPP2 —— IP标准校验和算法深度剖析:从原理到SSE2优化实现
网络·c++·网络协议·tcp/ip·算法·ip·通信
田里的水稻6 小时前
C++_队列编码实例,从末端添加对象,同时把头部的对象剔除掉,中的队列长度为设置长度NUM_OBJ
java·c++·算法
Jayden_Ruan7 小时前
C++逆向输出一个字符串(三)
开发语言·c++·算法
liulun7 小时前
Skia如何渲染 Lottie 动画
c++·动画
点云SLAM8 小时前
C++ 常见面试题汇总
java·开发语言·c++·算法·面试·内存管理
YuTaoShao9 小时前
【LeetCode 每日一题】1277. 统计全为 1 的正方形子矩阵
算法·leetcode·矩阵
野犬寒鸦9 小时前
力扣hot100:相交链表与反转链表详细思路讲解(160,206)
java·数据结构·后端·算法·leetcode
阿昭L9 小时前
leetcode两数之和
算法·leetcode
UnnamedOrange10 小时前
ROS2 配置 linter 的代码格式化工具为 clang-format
c++·cmake