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: ...
随机推荐
- PostgreSQL中的时间操作总结
取当前日期的函数: (1) 取当前时间:select now() (2) 取当前时间的日期: select current_date (3) 取当前具体时间(不含日 ...
- 点击自动显示/隐藏DIV代码。(简单实用)
注:本文由Colin撰写,版权所有!转载请注明原文地址,谢谢合作! 很多时候我们需要将DIV的信息默认为隐藏状态,只有当用户点击时才显示DIV中包含的提示文字.这类效果在互联网上应用得很多,但实现的方 ...
- 黄学长模拟day1 球的序列
N个编号为1-n的球,每个球都有唯一的编号.这些球被排成两种序列,分别为A.B序列,现在需要重新寻找一个球的序列l,对于这个子序列l中任意的两个球,要求j,k(j<k),都要求满足lj在A中位置 ...
- [AngularJS] 常用指令
常用指令 ng-hide指令,用于控制部分HTML元素可见(ng-hide="false")和不可见状态(ng-hide="true"),如下: <div ...
- Ubuntu 12 编译安装 PHP 5.4 及 问题汇总
参考先前的文章:Ubuntu 14 编译安装 PHP 5.4.45 + Nginx 1.4.7 + MySQL 5.6.26 笔记 安装过程: ############################ ...
- Chrome Restful Api 测试工具 Postman-REST-Client离线安装包下载,Axure RP Extension for Chrome离线版下载
[Postman for Chrome 离线下载] Postman-REST-Client离线安装包,可直接在Chrome浏览器本地安装使用,可模拟各种http请求,Restful Api测试, CS ...
- CentOS 6.5 3.0.4安装agentd
更改主机名为test3 [root@localhost ~]# cat /etc/sysconfig/network NETWORKING=yes HOSTNAME=test3 关闭selinux [ ...
- android Activity基类通用方法
public class BaseActivity extends Activity { Resources res; // 通用资源缩写 @Override protected void onCre ...
- Android应用反破解的思路
一个Android应用要被破解,要经历:反编译->分析代码->重新编译打包的过程,反破解的思路也是从在这三个步骤上做文章: 1, 寻找反编译工具的缺陷,通过阅读其源码或者对其进行压力测试找 ...
- ModelAndView的介绍
ModelAndView的构造方法有7个.但是它们都是相通的.这里使用无参构造函数来举例说明如何构造ModelAndView实例. ModelAndView类别就如其名称所示,是代表了MVC Web程 ...