POJ 1995 - Raising Modulo Numbers(数学`快速幂运算)
来源:互联网 发布:qq for linux ubuntu 编辑:程序博客网 时间:2024/05/16 02:31
题目:
http://poj.org/problem?id=1995
思路:
快速幂运算,模版题。
CODE:
#include <iostream>#include <cstdio>#include <cmath>using namespace std;typedef long long ll;int m;ll cal(ll a, ll b){ ll s = 1; while(b > 0) { if(b & 1) s = s * a % m; a = a * a % m; b >>= 1; } return s;}int main(){//freopen("in", "r", stdin); int T; scanf("%d", &T); while(T--) { int n; ll a, b, ans = 0; scanf("%d %d", &m, &n); while(n--) { scanf("%lld %lld", &a, &b); ans = (ans + cal(a, b)) % m; } printf("%I64d\n", ans); } return 0;}
0 0
- POJ 1995 - Raising Modulo Numbers(数学`快速幂运算)
- POJ 1995 Raising Modulo Numbers【快速幂】
- poj 1995 Raising Modulo Numbers 【快速幂】
- POJ 1995:Raising Modulo Numbers 快速幂
- poj 1995 Raising Modulo Numbers【快速幂】
- POJ - 1995 Raising Modulo Numbers 【快速幂】
- |poj 1995|快速幂|Raising Modulo Numbers
- POJ.1995 Raising Modulo Numbers (快速幂)
- POJ 1995 Raising Modulo Numbers 快速幂
- Raising Modulo Numbers 【poj-1995】【快速幂】
- 【POJ 1995】Raising Modulo Numbers(快速幂)
- poj 1995 Raising Modulo Numbers(快速幂)
- POJ 1995 Raising Modulo Numbers (数论-整数快速幂)
- POJ 题目1995 Raising Modulo Numbers(快速幂)
- POJ 1995 Raising Modulo Numbers (快速幂)
- poj 1995 Raising Modulo Numbers 【(64位)快速幂】
- Raising Modulo Numbers(poj 1995 快速幂)
- POJ 1995 Raising Modulo Numbers(快速幂)
- 《Python核心编程》第四章练习解析
- 《手游开发笔记-1》
- 郑风田:老美哪些地儿值得咱们?
- poj1064 Cable master
- Pattern Evaluation
- POJ 1995 - Raising Modulo Numbers(数学`快速幂运算)
- JS数组小结
- UVA - 10306 e-Coins
- UVA 624 CD
- Mac OSX安装brew
- POJ-3450-Corporate Identity(KMP)
- 对一道简单例题不同解法的感受
- c#中is关键字与as关键字的区别与使用
- 分支-08. 高速公路超速处罚(15)