Leetcode 372. Super Pow (Medium) (cpp)
来源:互联网 发布:ubuntu wubi安装教程 编辑:程序博客网 时间:2024/05/11 12:34
Leetcode 372. Super Pow (Medium) (cpp)
Tag: Math
Difficulty: Medium
/*372. Super Pow (Medium)Your task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array.Example1:a = 2b = [3]Result: 8Example2:a = 2b = [1,0]Result: 1024*/class Solution {public:int superPow(int a, vector<int>& b) {if (a % 1337 == 0) return 0;int p = 0;for (int i : b) p = (p * 10 + i) % 1140;if (p == 0) p += 1140;return power(a, p, 1337);}int power(int x, int n, int mod) {int ret = 1;for (x %= mod; n; x = x * x % mod, n >>= 1) if (n & 1) ret = ret * x % mod;return ret;}};
0 0
- Leetcode 372. Super Pow (Medium) (cpp)
- Leetcode 372. Super Pow[medium]
- Leetcode 50. Pow(x, n) (Medium) (cpp)
- leetcode.372. Super Pow
- LeetCode 372. Super Pow
- [LEETCODE] 372. super pow
- LeetCode--372. Super Pow
- leetcode 372. Super Pow
- Leetcode 372. Super Pow
- [leetcode] 372. Super Pow
- Leetcode: 372.Super Pow
- 372. Super Pow(LeetCode)
- LeetCode 372. Super Pow
- [LeetCode]372. Super Pow
- [leetcode]372. Super Pow
- leetcode 372. Super Pow
- LeetCode—372. Super Pow
- [leetcode] 372. Super Pow 解题报告
- php栈
- Java中抽象类实现多态
- com.sun.mail.smtp.SMTPSendFailedException: 554 DT:SPM 163 smtp11,D8CowAC3cuDofbZXKWsnCw--.47929S2 14
- Extract tables from messy spreadsheets with jailbreakr
- ionic实战之实现图片列表以及图片浏览
- Leetcode 372. Super Pow (Medium) (cpp)
- android inflate方法
- http://user.qzone.qq.com/314154775/infocenter#!app=2&via=QZ.HashRefresh&pos=1335594212
- 代码中动态和布局文件中静态改变Edittext光标样式方法
- SVN提交项目冲突
- Objective-C runtime
- 详解第二组UI组件:TextView及其子类
- 欢迎使用CSDN-markdown编辑器
- C语言文件操作函数大全