阶乘总和

  题目大意:要你算一堆阶乘对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. Linux内核循环链表经典分析和移植

    为什么说这个链表做的经典呢,哥哥我从Linux内核里边儿扣出来的,要么怎么说内核不是一般人能写的,这代码太TM优美了! 这里有一篇参考文章:http://isis.poly.edu/kulesh/st ...

  2. JS抽奖功能代码

    HTML <label for="awardListDom">奖项列表</label><br> <input type="tex ...

  3. C# Winform 脱离 Framework (一)

    Linker是一个命令行工具,它以将我们的.net程序生成可脱离.net framework环境运行的程序 . Linker不支持中文的路径,在程序中也不能有中文的标识符. Linker 有2种部署方 ...

  4. Linux运维初级教程(四)shell简介

    查看系统可用的shell命令 cat /etc/shells shell是用于与内核进行交流的工具 管道和重定向(< < > > |) |为管道 标准输入的文件描述符为0,标准 ...

  5. SQLite初试...

    string dataPath = "../../UserData.dbx"; //System.IO.Directory.GetCurrentDirectory() + &quo ...

  6. 重温javascript事件机制

    以前用过一段时间的jquery感觉太方便,太强大了,各种动画效果,dom事件.创建节点.遍历.控件及UI库,应有尽有:开发文档也很多,网上讨论的问题更是甚多,种种迹象表明jquery是一个出色的jav ...

  7. VS2008上借助VA来提示QT API

    1.打开VS,工具-->选项-->项目和解决方案-->VC++目录,在右侧下拉框中选择-->包含文件,添加QT的include目录 2. 打开VA配置页,Projects--& ...

  8. 机器学习之Hash集合问题

    问题来源与七月学习之 (3.x线性代数与矩阵运算基础)

  9. Ubuntu 12 安装 搜狗输入法

    下载地址:http://pinyin.sogou.com/linux/?r=pinyin Ubuntu 12 中,安装搜狗输入法注意事项 http://pinyin.sogou.com/linux/h ...

  10. git之create local reposition(创建本地仓库)

    1.创建名为git-reposition的仓库 mkdir home/sunjf/git-reposition 注:home/sunjf可以指定为你想要的路径下面 2.初始化仓库 cd ~/git-r ...