|poj 1995|快速幂|Raising Modulo Numbers
来源:互联网 发布:软件开发工作计划 编辑:程序博客网 时间:2024/05/17 02:38
poj传送门
根据题目公式
快速幂即可
#include<cstdio> #include<algorithm> #include<cstring> #include<cmath>#define ms(i,j) memset(i,j, sizeof i);using namespace std;#define ll long longint h;ll m;ll ans;ll poww(ll a, ll b){ ll ans = 1, base = a%m; while (b!=0) { if (b&1!=0) { ans = (ans*base)%m; } base = (base*base)%m; b>>=1; } return ans;}int main() { int kase; scanf("%d", &kase); while (kase--) { scanf("%lld%d", &m, &h); ans = 0; for (int i=1;i<=h;i++) { ll a,b; scanf("%lld%lld", &a, &b); ans = (ans+poww(a,b))%m; } printf("%d\n", ans%m); } 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 快速幂
- Raising Modulo Numbers 【poj-1995】【快速幂】
- 【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 Raising Modulo Numbers 【快速幂 + 模取余】
- poj 1995 Raising Modulo Numbers(快速幂)
- poj 1995 Raising Modulo Numbers 快速模幂
- POJ 1995 Raising Modulo Numbers 整数快速幂
- ACM书中题目——O
- 详解哈希表查找
- 挂起任务OSTaskSuspend()
- GPLT L2-003. 月饼【贪心】
- L1-007. 念数字
- |poj 1995|快速幂|Raising Modulo Numbers
- struts 学习之四(struts 数据类型转换)
- CSS3形变——transform与transform-origin画时钟
- Spring Security 配置类实现(2)
- React 笔记
- Java并发学习1
- Houston, we have a problem
- LeetCode 240. Search a 2D Matrix II
- 聊一聊C语言变量