lintcode-快速幂-125
来源:互联网 发布:北京电视台网络直播 编辑:程序博客网 时间:2024/05/25 18:11
计算an % b,其中a,b和n都是32位的整数。
样例
例如 231 % 3 = 2
例如 1001000 % 1000 = 0
挑战
O(logn)
class Solution {public: int fastPower(int a, int b, int n) { if(0==n) return 1%b; if(1==n) return a%b; long Pow=fastPower(a,b,n/2); Pow=(Pow*Pow)%b; if(n&1) return (a*Pow)%b; return Pow; }};
0 0
- lintcode-快速幂-125
- LintCode-快速幂
- Lintcode快速幂
- LintCode 快速幂
- Lintcode 快速幂
- lintcode之快速幂
- lintcode ----快速幂
- LintCode 140-快速幂
- LintCode :快速幂
- lintcode(140)快速幂
- 快速幂-LintCode
- [LintCode]140.快速幂
- 快速幂—LintCode
- [LintCode] 快速幂 Fast Power
- LintCode-剑指Offer-(140)快速幂
- lintcode刷题——快速幂
- LintCode
- lintcode--
- 高斯(核)函数简介
- 黑马程序员——面向对象
- Android handler机制的原理
- OC基础-拷贝
- Tomcat Gzip配置
- lintcode-快速幂-125
- Python操作MySQL数据库示例
- 除了xlog,哪些操作可能还需要fsync ?
- W3C标准
- 小笔记)自定义的activity样式宽度不能充满父窗体
- IOS网络笔记--图片上传服务器Demo
- Android开发者指南-摄像头-Camera
- [转]Apache Ignite——新一代数据库缓存系统
- 软件功能测试基础