CSU 1556 快速幂
来源:互联网 发布:miss淘宝店网址多少 编辑:程序博客网 时间:2024/05/20 04:27
J - J
Time Limit:10000MS Memory Limit:262144KB 64bit IO Format:%lld & %lluDescription
Jerry is caught by Tom. He was penned up in one room with a door, which only can be opened by its code. The code is the answer of the sum of the sequence of number written on the door. The type of the sequence of number is
But Jerry’s mathematics is poor, help him to escape from the room.
Input
There are some cases (about 500). For each case, there are two integer numbers n, m describe as above ( 1 <= n < 1 000 000, 1 <= m < 1000).
Output
For each case, you program will output the answer of the sum of the sequence of number (mod 1e9+7).
Sample Input
4 15 14 25 24 3
Sample Output
10153055100
题解:题意很难看懂,或者根本看不懂,给个第一个样例吧:1^1+2^1+3^1+4^1=10;大概就是这样
题解:快速幂就可以了
#include<iostream>#include<cstring>#include<cstdio>#include<algorithm>#include<set>#include<vector>#include<map>using namespace std;#define maxn 100001#define LL long long#define CLR(x) memset(x,0,sizeof(x))#define mod 1000000007LL pow_mod(LL a,LL n,LL m){if(n==0)return 1;LL x=pow_mod(a,n/2,m);LL ans=x*x%m;if(n%2==1)ans=ans*a%m;return ans;}int main(){#ifdef CDZSCfreopen("i.txt","r",stdin);#endifLL x,y;while(~scanf("%lld%lld",&x,&y)){LL sum=0;for(LL i=1;i<=x;i++){sum+=pow_mod(i,y,mod);}printf("%lld\n",sum%mod);}return 0;}
0 0
- CSU 1556 快速幂
- csu 1556: Jerry's trouble(快速幂)
- CSU - 1556 Jerry's trouble(快速幂)
- CSU 1556-Jerry's trouble(快速幂)
- 快速幂 --- CSU 1556: Jerry's trouble
- CSU - 1556 Jerry's trouble(快速幂取模)
- csu 1556: Jerry's trouble (快速幂取模)
- CSU 1658 IQ of XUEXX’s descendants 矩阵快速幂
- CSU 1162 Balls in the Boxes 快速幂 水
- 文章标题 CSU 1831: Found(矩阵快速幂)
- CSU 1233: 病毒的复制 矩阵快速幂
- CSU OJ:1347 Last Digitn(找规律||找周期+快速幂)
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- cc2530裸机编程系列笔记3--定时器Timer1自由模式程序
- 搞定HTML\CSS之background属性
- 【IO模型探讨】阻塞,非阻塞,同步,异步
- Git基本的工作流程
- Shiro介绍(二):从简单的认证开始
- CSU 1556 快速幂
- 错误总结:ERROR:ITMS-90032
- Qt 创建上下文菜单
- python核心编程-filter函数
- poj Repeater 3768 (模拟&&dfs) 好题
- HDOJ 5289 Assignment 【RMQ 二分 || 单调队列】
- android html解析
- cmd正则表达式批量重命名
- 容器的同步控制与只读设置JAVA133