【leetcode】372. Super Pow【M】【40】
2016-07-12 16:11
344 查看
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:
Example2:
Credits:
Special thanks to @Stomach_ache for adding this problem and creating all test cases.
Subscribe to see which companies asked this question
对幂,每一位进行计算
需要注意的一个地方就是,每一位升到上一位的时候,是十次幂
given in the form of an array.
Example1:
a = 2 b = [3] Result: 8
Example2:
a = 2 b = [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(object): def superPow(self, a, b): a = a % 1337 res = a ** b[0] % 1337 for i in b[1:]: res = res ** 10 * (a ** i) % 1337 res %= 1337 return res
相关文章推荐
- 欧拉函数/欧拉定理
- matlab 文件目录及路径操作
- MyEclipse里运行Tomcat后,Console窗口里中文显示乱码
- LaTeX中插入eps格式图片
- c# 串口通信
- WPF窗体样式继承
- Android 自定义组合控件
- ThinkPHP5开发(三)使用Behavior检测用户登录状态
- <!DOCTYPE> 声明
- 【POJ 1182】食物链(并查集)
- 使用PorterDuffXfermode画出刮刮奖效果p146-p148
- FileUpload上传Excel文件,Aspose导入数据至数据库(web)
- Gadgets-MD5加密
- TextSwitcher 跑马灯算法完善
- html用js实现导航栏的二级菜单,自动伸缩。。。
- Eclipse Java注释模板设置详解
- 10集合映射
- Android系统Choreographer机制实现过程
- 角色 权限
- csv转mongodb