super-pow
2016-07-10 14:10
417 查看
// https://discuss.leetcode.com/topic/50489/c-clean-and-short-solution class Solution { int base = 1337; int powMod(int a, int b) { a %= base; int result = 1; for (int i=0; i<b; i++) { result *= a; result %= base; } return result; } public: int superPow(int a, vector<int>& b) { if (b.empty()) { return 1; } int t = b.back(); b.pop_back(); return (powMod(superPow(a, b), 10) * powMod(a, t)) % base; } };
相关文章推荐
- 图文解析gravity与layout_gravity的差异
- 水仙花数
- Android Netd
- 终于有人把P2P、P2C、O2O、B2C、B2B、C2C 的区别讲透了!
- prefix和unprefix
- 贪心算法-Huffman编码
- 扩展欧几里得 exgcd
- SQLite--简单的数据库
- 如何在doc窗口下,切换到其他路径
- leetcode_c++:哈希:Count Primes (204)
- Javascript 理解 __proto__ 和 prototype以及instance
- SpringSecurity方法层4种方式使用
- 关于获取用户当前位置
- git使用教程
- 我也吐槽
- 不规则形状的Mask动画
- Java中Object对象的hashCode方法和String对象的hashCode
- c文件函数转载
- Lucene建立索引 使用IKAnalyzer扩展词库
- 主页