POJ 1995 Raising Modulo Numbers
快速幂取模
#include<cstdio> int mod_exp(int a, int b, int c)
{
int res, t;
res = % c;
t = a % c;
while (b)
{
if (b & ) res = res * t % c;
t = t * t % c;
b >>= ;
}
return res;
} int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int m,h;
scanf("%d%d",&m,&h);
int ans=;
for(int i=; i<=h; i++)
{
int a,b;
scanf("%d%d",&a,&b);
ans=(ans+mod_exp(a,b,m))%m;
}
printf("%d\n",ans);
}
return ;
}
POJ 1995 Raising Modulo Numbers的更多相关文章
- poj 1995 Raising Modulo Numbers【快速幂】
Raising Modulo Numbers Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5477 Accepted: ...
- poj 1995 Raising Modulo Numbers 题解
Raising Modulo Numbers Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 6347 Accepted: ...
- POJ 1995 Raising Modulo Numbers 【快速幂取模】
题目链接:http://poj.org/problem?id=1995 解题思路:用整数快速幂算法算出每一个 Ai^Bi,然后依次相加取模即可. #include<stdio.h> lon ...
- POJ 1995 Raising Modulo Numbers(快速幂)
嗯... 题目链接:http://poj.org/problem?id=1995 快速幂模板... AC代码: #include<cstdio> #include<iostream& ...
- POJ 1995 Raising Modulo Numbers (快速幂)
题意: 思路: 对于每个幂次方,将幂指数的二进制形式表示,从右到左移位,每次底数自乘,循环内每步取模. #include <cstdio> typedef long long LL; LL ...
- Raising Modulo Numbers(POJ 1995 快速幂)
Raising Modulo Numbers Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5934 Accepted: ...
- 【POJ - 1995】Raising Modulo Numbers(快速幂)
-->Raising Modulo Numbers Descriptions: 题目一大堆,真没什么用,大致题意 Z M H A1 B1 A2 B2 A3 B3 ......... AH ...
- POJ 1995:Raising Modulo Numbers 快速幂
Raising Modulo Numbers Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5532 Accepted: ...
- POJ1995 Raising Modulo Numbers
Raising Modulo Numbers Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 6373 Accepted: ...
随机推荐
- python3 与 python2的 区别比较
http://sebug.net/paper/books/dive-into-python3/porting-code-to-python-3-with-2to3.html
- vi编辑器常见命令的使用
Linux下的文本编辑器有很多种,vi 是最常用的,也是各版本Linux的标配.注意,vi 仅仅是一个文本编辑器,可以给字符着色,可以自动补全,但是不像 Windows 下的 word 有排版功能. ...
- keepalived: Compile & startup
first get keepalived source from git: git clone https://github.com/acassen/keepalived then unzip and ...
- jquery获得select的文本
本来以为jQuery("#select1").val();是取得选中的值, 那么jQuery("#select1").text();就是取得的文本. 这是不正确 ...
- L2,breakfast or lunch
express: what a day多么糟糕的天气 I‘m coming to see you我将要来看你 what a lot of trouble he is causing他犯了多少错误啊 w ...
- Yii config 配置
Yii2 配置文件 常用配置总结 <?php // 主配置文件 $config = array( 'modules' => array( 'gii' => array( 'class ...
- 一个opencv 博客 大量文章(老版本编写C )
http://blog.csdn.net/Augusdi/article/category/747412
- 第11章 类的高级特性--final
1.final变量 (1)final关键字可用于变量声明,一旦该变量被设定,就不可以再改变该变量的值.通常,由final定义的变量为常量.例如:final double PI=3.14; final关 ...
- STM32 IAP 固件升级设计/U盘升级固件
源:STM32 IAP 固件升级设计/U盘升级固件 固件升级的基本思路是: 将stm32 的flash划分为两个区域: 1.Bootloader区:存放bootloader的代码,bootloader ...
- HTTPS与SSL
---------------------------------------------------------------------------------------------------- ...