E - A^B mod C (大数乘方取模)
2024-09-04 22:23:37
Description
Given A,B,C, You should quickly calculate the result of A^B mod C. (1<=A,B,C<2^63).
Input
There are multiply testcases. Each testcase, there is one line contains three integers A, B and C, separated by a single space.
Output
For each testcase, output an integer, denotes the result of A^B mod C.
Sample Input
3 2 4
2 10 1000
Sample Output
1
24
解题思路:直接调用BigInteger大数类中的modPow(n,m)方法即可,java简单水过!
AC代码:
import java.util.Scanner;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while(scan.hasNext()){
BigInteger a = scan.nextBigInteger();
BigInteger b = scan.nextBigInteger();
BigInteger c = scan.nextBigInteger();
System.out.println(a.modPow(b,c));//大整数乘方和取模
}
}
}
最新文章
- Unity WebGL MoonSharp崩溃问题
- shell小细节
- WebUploader IE9下报错
- StringBuilder、StringBuffer和String三者的联系和区别(转)
- discuz X3.1的门户文章实现伪静态,利于搜索引擎收录url的地址修改
- set集合容器
- ng-init小解
- 转:运行page页面时的事件执行顺序及页面的回发与否深度了解
- Nginx与Lua
- GDKOI2017滚粗记
- Tensorflow object detection API ——环境搭建与测试
- git GUI设置长期记住密码
- linux下编写C++程序播放音频
- YUM仓库服务与PXE网络装机
- 步步为营-57-JQuery练习题
- bytes和str的区别与转换
- Redis集群错误
- angular封装jquery插件(组件)
- 如何阻止点击scrollviewer里面的单位内容时,自动滚动
- EL表达式获取值栈数据
热门文章
- 【BZOJ3669】魔法森林(LCT)
- 【Tomcat】tomcat启动后查看运行时JVM参数
- ZOJ - 3829 Known Notation(模拟+贪心)
- Codeforces 629D Babaei and Birthday Cake(树状数组优化dp)
- SpringBoot学习day01
- 前端自动化测试工具--使用karma进行javascript单元测试(转)
- yarn-cli 显示文件目录
- create-react-app 引入 antd 及 解决 antd 样式无法显示的bug
- Android上拉查看详情实现
- 安装eclipse中html/jsp/xml editor插件以及改动html页面的字体