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));//大整数乘方和取模
}
}
}

最新文章

  1. Unity WebGL MoonSharp崩溃问题
  2. shell小细节
  3. WebUploader IE9下报错
  4. StringBuilder、StringBuffer和String三者的联系和区别(转)
  5. discuz X3.1的门户文章实现伪静态,利于搜索引擎收录url的地址修改
  6. set集合容器
  7. ng-init小解
  8. 转:运行page页面时的事件执行顺序及页面的回发与否深度了解
  9. Nginx与Lua
  10. GDKOI2017滚粗记
  11. Tensorflow object detection API ——环境搭建与测试
  12. git GUI设置长期记住密码
  13. linux下编写C++程序播放音频
  14. YUM仓库服务与PXE网络装机
  15. 步步为营-57-JQuery练习题
  16. bytes和str的区别与转换
  17. Redis集群错误
  18. angular封装jquery插件(组件)
  19. 如何阻止点击scrollviewer里面的单位内容时,自动滚动
  20. EL表达式获取值栈数据

热门文章

  1. 【BZOJ3669】魔法森林(LCT)
  2. 【Tomcat】tomcat启动后查看运行时JVM参数
  3. ZOJ - 3829 Known Notation(模拟+贪心)
  4. Codeforces 629D Babaei and Birthday Cake(树状数组优化dp)
  5. SpringBoot学习day01
  6. 前端自动化测试工具--使用karma进行javascript单元测试(转)
  7. yarn-cli 显示文件目录
  8. create-react-app 引入 antd 及 解决 antd 样式无法显示的bug
  9. Android上拉查看详情实现
  10. 安装eclipse中html/jsp/xml editor插件以及改动html页面的字体