poj 1995(快速幂)
来源:互联网 发布:新ipad壁纸软件 编辑:程序博客网 时间:2024/05/22 06:54
题意:本题给出h组数每组两个数,ai,bi,求解 ;
分析:没啥好说的,一个裸的快速幂:
Source Code#include <set>#include <map>#include <stack>#include <queue>#include <math.h>#include <vector>#include <string>#include <utility>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <iostream>#include <algorithm>#include <functional>using namespace std;long long quick_mod(long long a,long long b,long long m){ long long ans=1; while(b){ if(b&1){ ans=(ans*a)%m; b--; } b/=2; a=a*a%m; } return ans;}int main(){ int t; scanf("%d",&t); while(t--){ int a,b; int m; int h; scanf("%d%d",&m,&h); long long sum=0; while(h--){ scanf("%d%d",&a,&b); sum=(sum+quick_mod(a,b,m))%m; } printf("%I64d\n",sum%m); } return 0;}
0 0
- poj 1995(快速幂)
- poj 1995 快速幂
- POJ 1995 快速幂
- poj 1995 快速幂
- poj 1995 (快速幂) poj 3233(矩阵快速幂)
- POJ 1995 快速幂 基础
- 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(快速幂)
- POJ 1995 Raising Modulo Numbers(快速幂)
- POJ:1995 Raising Modulo Numbers(快速幂)
- POJ-1995 Raising Modulo Numbers(快速幂简单应用)
- 2017阿里一面面经
- Number 类,是八大基本类型的 父类
- HDU 5137 How Many Maos Does the Guanxi Worth
- Java如何复制对象
- eclipse实现Java源代码查看配置是如何查看JDK安装路径
- poj 1995(快速幂)
- CodeForces 4D Mysterious Present(DP)
- Centos7 yum安装nginx
- 关于爱丽丝和鲍勃的宴后演讲
- Java学习资源
- 【json】数组和对象转换为json
- 分享一下最近收集的hadoop视频资料
- 内部跳转和外部跳转
- leetcode——225—— Implement Stack using Queues