372. Super Pow
来源:互联网 发布:ios软件开发语言 编辑:程序博客网 时间:2024/05/17 23:58
Your task is to calculate ab mod 1337 where a is a positive integer andb is an extremely large positive integer given in the form of an array.
Example1:
a = 2b = [3]Result: 8
Example2:
a = 2b = [1,0]Result: 1024
Credits:
Special thanks to @Stomach_ache for adding this problem and creating all test cases.
Subscribe to see which companies asked this question
class Solution {public: static const int base = 1337; int pown(int a,int b) { a%=base; int result = 1; for(int i=0;i<b;++i) { result=(result*a)%base; } return result; } int superPow(int a, vector<int>& b) { if(b.empty()) return 1; int k = b.back(); b.pop_back(); return pown(superPow(a,b),10)*pown(a,k)%base; }};
0 0
- leetcode.372. Super Pow
- LeetCode 372. Super Pow
- 372. Super Pow
- 372. Super Pow
- [LEETCODE] 372. super pow
- LeetCode--372. Super Pow
- 372. Super Pow
- leetcode 372. Super Pow
- Leetcode 372. Super Pow
- [leetcode] 372. Super Pow
- Leetcode: 372.Super Pow
- 372. Super Pow
- 372. Super Pow(LeetCode)
- 372. Super Pow
- LeetCode 372. Super Pow
- 372. Super Pow
- [LeetCode]372. Super Pow
- 372. Super Pow
- hdu 3549 Flow Problem【Dinic最大流】
- 51nod1486 大大走格子
- Java线程安全与不安全
- phpexcel
- poj 2253 Frogger
- 372. Super Pow
- STL源码剖析(四)---空间配置器
- 省市县三级联动
- 样式化复选框(Styling checkbox) & 扩展实现“开关按钮效果”
- JAVA单例模式的几种方法
- Linux:shell完美获取上月,本月,下月年月
- 单链表的整表创建
- shell实现磁盘分区由MBR转换为GPT
- 给 Android 开发者的 RxJava 详解