swust.oj.303
来源:互联网 发布:淘宝店铺运营案例 编辑:程序博客网 时间:2024/06/05 09:02
取模(0303)
Time limit(ms): 1000
Memory limit(kb): 65535
Submission: 1658
Accepted: 534
Accepted
15级卓越班选拔C16级卓越班选拔C 14级卓越班选拔C14级卓越班选拔C
给你三个数X(1<=X<=10^100)、Y(1<=Y<=10^8)、Z(1<=Z<=10^4),你能计算出X^Y%Z的值吗?
Description
输入三个如上所描述的数X、Y、Z。多组输入。
Input
输出X^Y%Z的值。
Output
2 3 5
12345 2345 345
123456789123456789 19234321 2341
Sample Input
3
240
1825
#include <iostream>#include <stdio.h>#include<string.h>using namespace std;int main(){char x[100];int y, z;while (cin >> x >> y >> z){int t = 0;for (int i = 0; i < strlen(x); i++){t = (t * 10 + x[i] - '0') % z;}//我也很迷啊,不知道这里是什么原理int ans = 1;while (y){if (y % 2)ans = (ans*t) % z;y = y / 2;t = (t*t) % z;}//快速幂cout << ans << endl;}return 0;}
0 0
- swust.oj.303
- SWUST OJ 1025
- SWUST OJ 1137 STICKS
- SWUST OJ 1804 二进制
- swust OJ 1515
- swust OJ 1619 中位数
- SWUST OJ 2285
- swust.oj 0259
- swust.oj 0964
- swust.oj,0541
- swust.oj.319
- swust.oj.1013
- swust.oj.1015
- swust.oj.1072
- swust.oj.1076
- swust.oj.1075
- swust.oj.1075
- swust oj 2620
- url地址访问不到,报404
- 如何屏蔽StatusBar和NavigationBar
- lua 数组
- Linx学习篇之~unit13练习
- mysql create database 指定utf-8编码
- swust.oj.303
- OGNL表达式
- 关于纯java连接数据TCP/IP连接不成功的提示
- Bugly的使用
- LeetCode题解–137. Single Number II
- OpenGL坐标变换 平移,缩放与旋转
- unity编译时找不到AndroidSDK:Unable to list target platforms
- 由if-else,switch代替方案引起的思考
- 接收广播的两种方法