1. // https://discuss.leetcode.com/topic/50489/c-clean-and-short-solution
  2.  
  3. class Solution {
  4. int base = ;
  5. int powMod(int a, int b) {
  6. a %= base;
  7. int result = ;
  8. for (int i=; i<b; i++) {
  9. result *= a;
  10. result %= base;
  11. }
  12. return result;
  13. }
  14.  
  15. public:
  16. int superPow(int a, vector<int>& b) {
  17. if (b.empty()) {
  18. return ;
  19. }
  20. int t = b.back();
  21. b.pop_back();
  22.  
  23. return (powMod(superPow(a, b), ) * powMod(a, t)) % base;
  24.  
  25. }
  26. };

super-pow的更多相关文章

  1. leetcode 50. Pow(x, n) 、372. Super Pow

    50. Pow(x, n) 372. Super Pow https://www.cnblogs.com/grandyang/p/5651982.html https://www.jianshu.co ...

  2. [LeetCode] Super Pow 超级次方

    Your task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large posi ...

  3. [Swift]LeetCode372. 超级次方 | Super Pow

    Your task is to calculate ab mod 1337 where a is a positive integer and bis an extremely large posit ...

  4. 372 Super Pow 超级次方

    你的任务是计算 ab 对 1337 取模,a 是一个正整数,b 是一个非常大的正整数且会以数组形式给出.示例 1:a = 2b = [3]结果: 8示例 2:a = 2b = [1,0]结果: 102 ...

  5. LeetCode——372. Super Pow

    题目链接:https://leetcode.com/problems/super-pow/description/ Your task is to calculate ab mod 1337 wher ...

  6. 【LeetCode】372. Super Pow 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/super-po ...

  7. 372. Super Pow

    问题 Your task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large p ...

  8. leetcode Super Pow

    题目描述: superPow(int a, int[] b),b是一个int数组,每个元素都是正的个位数,组合起来表示一个正整数,例如b=[1,2,3]表示123,求解a^b mod 1337. 思路 ...

  9. Leetcode 372. Super Pow

    使用公式 c = ab  =>  c mod d = [a mod d * b mod d] mod d 所以a^423 mod d = (a^100)^4 * (a ^10)^2 * a^3 ...

  10. 372. Super Pow.txt

    ▶ 指数取模运算 ab % m ▶ 参考维基 https://en.wikipedia.org/wiki/Modular_exponentiation,给了几种计算方法:暴力计算法,保存中间结果法(分 ...

随机推荐

  1. poj1847 Tram(Dijkstra || Floyd || SPFA)

    题目链接 http://poj.org/problem?id=1847 题意 有n个车站,编号1~n,每个车站有k个出口,车站的出口默认是k个出口中的第一个,如果不想从默认出口出站,则需要手动选择出站 ...

  2. 使用 AVA 做自动化测试

    http://colabug.com/710736.html

  3. Inno Setup使用

    Inno Setup是一个开源的安装包打包软件,下载地址是:http://www.jrsoftware.org/isdl.php 使用引导界面创建一个安装包打包 配置参考官方文档:http://www ...

  4. java 代理设计模式

    首先代理(deleration)是什么,在日常生活中我们有很多这种的例子,比如你上个QQ,各种空间被什么代理刷屏,对的,代理不是生产产品的商家,也不是进购产品的卖家,他们只是帮别人卖东西,这就相当于一 ...

  5. Servlet的一点小结

    1.什么是servlet servlet是一个Java applet,一个帮助程序.用于帮助浏览器从服务器中获取资源.浏览器-servlet-服务器三者的关系如图所示. 2.servlet的生命周期 ...

  6. hdu-4027线段树练习

    title: hdu-4027线段树练习 date: 2018-10-10 18:07:11 tags: acm 算法 刷题 categories: ACM-线段树 # 概述 这道线段树的题可以说是我 ...

  7. CLR基础

    一.各个语言的长处 ①非托管C/C++可对系统进行低级控制.可完全按照自己的想法管理内存,必要时方便地创建线程②使用Microsoft Visual Basic 6.0可以快速生成UI应用程序,并可以 ...

  8. poj1273(Edmonds-Karp)

    这道题可以算是例题了. 求解最大流,采用EK算法,用广搜查找增广路径,找到后更新网络流矩阵,循环执行直至找不到增广路径为止.这里要小心的是重复边的情况. 程序也是参照了网上的模版来写的,有一些技巧.如 ...

  9. [ 原创 ]linux centos下配置java环境教程

    一.环境 centos 7.2 二.目标 在CentOS7.2上安装jdk1.8(tar.gz安装包),并配置环境变量 jdk安装在/home/soft/jdk1.8.0-131目录下 具体步骤 1. ...

  10. CentOS---网络配置详解

    一.配置文件详解 在RHEL或者CentOS等Redhat系的Linux系统里,跟网络有关的主要设置文件如下: /etc/host.conf         配置域名服务客户端的控制文件 /etc/h ...