阶乘总和

  题目大意:要你算一堆阶乘对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)的更多相关文章

  1. Day7 - J - Raising Modulo Numbers POJ - 1995

    People are different. Some secretly read magazines full of interesting girls' pictures, others creat ...

  2. poj 1995 Raising Modulo Numbers【快速幂】

    Raising Modulo Numbers Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5477   Accepted: ...

  3. Raising Modulo Numbers(POJ 1995 快速幂)

    Raising Modulo Numbers Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5934   Accepted: ...

  4. poj 1995 Raising Modulo Numbers 题解

    Raising Modulo Numbers Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 6347   Accepted: ...

  5. 【POJ - 1995】Raising Modulo Numbers(快速幂)

    -->Raising Modulo Numbers Descriptions: 题目一大堆,真没什么用,大致题意 Z M H A1  B1 A2  B2 A3  B3 ......... AH  ...

  6. POJ 1995:Raising Modulo Numbers 快速幂

    Raising Modulo Numbers Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5532   Accepted: ...

  7. POJ1995 Raising Modulo Numbers

    Raising Modulo Numbers Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 6373   Accepted: ...

  8. POJ1995 Raising Modulo Numbers(快速幂)

    POJ1995 Raising Modulo Numbers 计算(A1B1+A2B2+ ... +AHBH)mod M. 快速幂,套模板 /* * Created: 2016年03月30日 23时0 ...

  9. poj1995 Raising Modulo Numbers【高速幂】

    Raising Modulo Numbers Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5500   Accepted: ...

随机推荐

  1. 一起找bug

    帮同学找的一个bug,错误代码如下: package dai_test; public class Test1 { public static void main(String[] args) { / ...

  2. Web前端开发规范文档(google规范)

    (Xee:其实没什么规范约束,但是养成一种好习惯,何乐而不为?) 区分大小写 xhtml  区分大小写,xhtml要求 标签名 属性名 值都要小写,并且要有双引号和 标签闭合. css 元素名称以及i ...

  3. Windows Phone自带的语音识别

    WindowsPhone下语音操作包括: 1.程序内部的语音识别,用户可以通过语音识别进行输入或完成相关任务 2.控制程序的语音命令,控制程序启动.打开,并可对页面跳转等进行操作 这篇文章将构建一个简 ...

  4. 必须知道的.net(字段、属性和方法)

    1.字段 通常定义为private(封装原则) 2.属性(property) 通常定义为public,表示类的对外成员.具有可读可写属性,通过get和set访问器实现 3.索引器(indexer) C ...

  5. java中堆和栈的区别

    从宏观上来讲,栈内存:存储基本数据类型.堆内存:存储实际的对象内容.说明白点就是new出来的东西. int a = 3; int b = 3; a = 4; 编译器首先会处理int a = 3;将a进 ...

  6. sql 2005,2008开启bcp的方法嗯哈步骤

    sqlserver 2008开启bcp服务的方法和步骤 sqlserver 2005开启bcp服务的方法和步骤 在开始菜单中找到sql server 2005 -->> 配置工具 --&g ...

  7. MongoDB的索引(三)

    MongoDB的索引: 1. _id索引 该索引是大多数集合默认创建的索引,也就是说用户每插入一个数据,MongoDB会自动生成一条唯一的_id字段. 2. 单键索引 单键索引是最普通的索引,它不会自 ...

  8. windowSoftInputMode属性讲解

    windowSoftInputMode属性讲解(下面这段内容我参考别人的博客,并加入我的一些意见) 我们从这个属性的名称中,可以很直观的看出它的作用,这个属性就是来设置窗口软键盘的交互模式的.andr ...

  9. jbuilder的set!方法重构接口

    https://github.com/rails/jbuilder  的set!方法重构接口, 因为grape没法使用 jBuilder 的缓存,所以直接用 Rails 写 API (1)多个图片 i ...

  10. leetcode 278. First Bad Version

    You are a product manager and currently leading a team to develop a new product. Unfortunately, the ...