HLG-1251(快速幂)
来源:互联网 发布:查看linux开机启动项 编辑:程序博客网 时间:2024/05/18 01:17
Marshal's Confusion III
Time Limit: 3000 MS Memory Limit: 65536 K
DescriptionTime Limit: 3000 MS Memory Limit: 65536 K
Marshallike to solve acm problems.But they are very busy, one day they meet a problem. Given three intergers a,b,c, the task is to compute a^(b^c))%317000011. so the turn to you for help.
Input
The first line contains an integer T which stands for the number of test cases. Each case consists of three integer a, b, c seperated by a space in a single line. 1 <= a,b,c <= 100000
Output
For each case, print a^(b^c)%317000011 in a single line.
Sample Input
2
1 1 1
2 2 2
Sample Output
1
16
//求a^b^c%317000011#include<iostream>using namespace std;int main(){long long int n;long long int a,b,c;cin>>n;while(n--){cin>>a>>b>>c;long long int sum=1;while(c--){ long long int s=a;sum=1; int k=b; while(k) {if(k&1){sum=sum*s%317000011;}s=s*s%317000011;k>>=1; } a=sum;}cout<<sum<<endl;}return 0;}
0 0
- HLG-1251(快速幂)
- HLG 1251 Marshal's Confusion III (快速幂)
- HLG 1905 f(N) 矩阵快速幂
- HLG-1126(矩阵乘法+快速幂)
- HLG-1375(矩阵乘法+快速幂)
- hrbust 1126 HLG 矩阵快速幂
- HLG 1126 Final Destination II(快速幂,矩阵乘法)
- HLG 1375 The Active Leyni (快速幂,动态规划,矩阵乘法)
- HLG 1251 Marshal's Confusion III
- HLG 2061
- HLG移动
- HLG 1181 移动
- HLG 1400 汽车比赛
- HLG 1186 青蛙过河
- poj 3253 HLG 2059
- HLG Warcraft III
- HLG 选美大赛
- HLG Catch The Cow
- Libcurl的编译_HTTP/HTTPS客户端源码示例
- FFMPEG结构体分析 AVCodec
- 关于读《windows程序设计 第五版》的总结及摘要
- 动态代理
- css
- HLG-1251(快速幂)
- x86 版的 Arduino Intel Galileo 开发板的体验、分析和应用
- 整理的8种排序算法的总结和比较
- IDL学习笔记(1)
- CSS
- Python知识点总结1--函数
- Libuci 独立于openwrt系统外的使用
- Windows x86和Windows x64的区别
- UVA - 10041 Vito's Family(贪心)