poj 1995 Raising Modulo Numbers 快速模幂
来源:互联网 发布:淘宝网是马云的吗 编辑:程序博客网 时间:2024/05/20 21:43
#include<iostream>using namespace std;int quick_mod(int a,int b,int m){ a=a%m; int ans=1; while(b) { if(b&1) { ans=(ans*a)%m; } b>>=1; a=(a*a)%m; } return ans;}int main(){ int size; cin>>size; int m; int h; int a,b; while(cin>>m) { cin>>h; int ans=0; for(int i=0;i<h;i++) { cin>>a>>b; ans=(ans+quick_mod(a,b,m))%m; } cout<<ans<<endl; }}
题目地址:http://poj.org/problem?id=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
- 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 快速幂取模
- Raising Modulo Numbers (poj 1995 快速幂水题)
- POJ 1995 Raising Modulo Numbers(快速幂取模)
- poj Raising Modulo Numbers 【快速幂 + 模取余】
- poj 1995 Raising Modulo Numbers(快速幂)
- POJ 1995 Raising Modulo Numbers 整数快速幂
- 暑假计划
- 【Python排序搜索基本算法】之选择排序
- Makefile 中:= ?= += =的区别
- ubuntu下Eclipse+CDT+GDB调试android NDK程序
- C++调用大数组出现栈溢出的问题解决方法,堆和栈的完全解析
- poj 1995 Raising Modulo Numbers 快速模幂
- “scanf扫描集”的初体验
- 【Python排序搜索基本算法】之冒泡排序
- github
- POJ3411--Paid Roads
- poj 3468 A Simple Problem with Integers(线段树区间更新 or 树状数组区间更新)
- UIKit 图片的移动、位移、旋转、缩放、翻转、翻页等特效的使用
- Makefile debug的经验
- TQ2440开发板open ssh移植