import java.io.*;
import java.math.*;
import java.util.*;
import java.text.*; public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
BigInteger a, b, m, ans;
while (cin.hasNext()) {
ans = new BigInteger("1");
a = cin.nextBigInteger();
b = cin.nextBigInteger();
m = cin.nextBigInteger();
a = a.mod(m);
while (b.compareTo(new BigInteger("0")) > 0) {
if (b.mod(BigInteger.valueOf(2)).compareTo(BigInteger.ONE) == 0) // if(n%2==1)
ans = ans.multiply(a).mod(m); // sq=(sq*p)%m;
a = a.multiply(a).mod(m); // p=(p*p)%m;
b = b.divide(BigInteger.valueOf(2));
}
System.out.println(ans);
}
}
}

最新文章

  1. MsSQLserver中修改字段值系统自动生成的脚本
  2. 张艾迪(创始人): 整合全新的UIW.AD概念模式
  3. webdriver无法打开firefox
  4. PHP面向对象04_串行化
  5. 安装mac os x时about a second remaining解决方法
  6. 浅谈Java回调机制
  7. 【ruby】ruby基础知识
  8. 删除Ngnix 日志
  9. Flume简介与使用(二)——Thrift Source采集数据
  10. web api 开发之 filter
  11. Buffett saying
  12. Hive 行列转换
  13. iPhone 屏幕分辨率
  14. Android开发的一些总结
  15. Linux命令--tree
  16. HDU1060
  17. wireless Penetration Testing & Honeypot and Mis-Association attacks
  18. SpringBoot使用thymeleaf模板引擎
  19. matlab中hold on 和hold off功能的区别
  20. (九)ROS安装rviz模拟器

热门文章

  1. Git 2.7: 一个新的带来许多新特性和性能提升的主要版本
  2. Ajax--xml格式及注意事项
  3. windows 查看端口被占用
  4. python3-day3(内置函数)
  5. (转)iOS7界面设计规范(10) - UI基础 - 文字排版与配色
  6. android widget 开发实例 : 桌面便签程序的实现具体解释和源代码 (上)
  7. 图像重采样(CPU和GPU)
  8. ASE中的主要数据库
  9. Oracle CheckPoint进程
  10. UIApplication的作用