Mathematics:Raising Modulo Numbers(POJ 1995)
题目大意:要你算一堆阶乘对m的模...
大水题,对指数二分就可以了。。。
#include <iostream>
#include <functional>
#include <algorithm> using namespace std; typedef long long LL_INT; LL_INT cal(const LL_INT, const LL_INT, const LL_INT); int main(void)
{
int case_sum, item_sum;
LL_INT mod, a, b, sum;
scanf("%d", &case_sum); while (case_sum--)
{
sum = ;
scanf("%lld%d", &mod, &item_sum);
for (int i = ; i < item_sum; i++)
{
scanf("%lld%lld", &a, &b);
sum = (sum + cal(a, b, mod)) % mod;
}
printf("%lld\n", sum);
}
return ;
} LL_INT cal(const LL_INT coe, const LL_INT pow, const LL_INT mod)
{
LL_INT x, y;
if (!pow)
return ;
x = cal(coe, pow >> , mod);
y = (x*x) % mod; if (pow % )
y = (coe*y) % mod;
return y;
}
Mathematics:Raising Modulo Numbers(POJ 1995)的更多相关文章
- Day7 - J - Raising Modulo Numbers POJ - 1995
People are different. Some secretly read magazines full of interesting girls' pictures, others creat ...
- poj 1995 Raising Modulo Numbers【快速幂】
Raising Modulo Numbers Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5477 Accepted: ...
- 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 Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 6347 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: ...
- POJ1995 Raising Modulo Numbers(快速幂)
POJ1995 Raising Modulo Numbers 计算(A1B1+A2B2+ ... +AHBH)mod M. 快速幂,套模板 /* * Created: 2016年03月30日 23时0 ...
- poj1995 Raising Modulo Numbers【高速幂】
Raising Modulo Numbers Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5500 Accepted: ...
随机推荐
- emlog在nginx中添加rewrite规则
rewrite ^/(post|record|sort|author|page)-([-]+)\.html$ /index.php?$=$; rewrite ^/tag-(.+)\.html$ /in ...
- Django 部署
话说这个部署挺折腾人的,先开始使用 mod_python ,貌似版本一直有问题,没成功过,以后再试. 使用 mod_wsgi 成功,记录如下: 1.下载 mod_wsgi: http://code.g ...
- JDBC:从数据库中取数据的一个bug
先看错误信息: java.sql.SQLException: Before start of result set at com.mysql.jdbc.SQLError.createSQLExcept ...
- 【开源一个小工具】一键将网页内容推送到Kindle
最近工作上稍微闲点,这一周利用下班时间写了一个小工具,其实功能挺简单但也小折腾了会. 工具名称:Simple Send to Kindle Github地址:https://github.com/zh ...
- HDOJ 4750 Count The Pairs
按边长从小到大排序...再逐个加入(就像MST一样)最先联通的点之间最长路径中的最小值就是新加入的边的长.... Count The Pairs Time Limit: 20000/10000 MS ...
- QT编写上位机程序一定要初始化变量以及谨慎操作指针
背景: 在编写QT上位机界面时,界面在运行的时候经常出现卡死或者直接挂掉的怪现象. 正文: 上位机有个函数为check_receive():该函数的作用为定时调用循环检测USB是否有数据.若有,则将信 ...
- 微信封号浪潮再起 A货假代购还能在朋友圈泛滥多久?
你的微信朋友圈是不是很活跃?是不是被很多所谓的名品所包围?没错,这些很多都是A货或假代购的伎俩.如果xmyanke的微信朋友圈出现这些东东,我就会直接屏蔽他的朋友圈权限.具体方法是:打开他的微信详细资 ...
- php综合应用
php面试题之五--PHP综合应用(高级部分) 五.PHP综合应用 1.写出下列服务的用途和默认端口(新浪网技术部) ftp.ssh.http.telnet.https ftp:File Transf ...
- php数据结构与算法
php面试题之二--数据结构和算法(高级部分) 二.数据结构和算法 1.使对象可以像数组一样进行foreach循环,要求属性必须是私有.(Iterator模式的PHP5实现,写一类实现Iterator ...
- FineUI第十二天---锚点布局
锚点布局的典型结构: <x:Panel Layout="Anchor" runat="server"> <Items ...