d636: 大爆炸bomb

題目:http://zerojudge.tw/ShowProblem?problemid=d636
程式碼:

import java.math.BigInteger;
import java.util.Scanner;
public class d636 {

 public static void main(String[] args) {
  // TODO Auto-generated method stub
  Scanner sc = new Scanner(System.in);
  final BigInteger mod = BigInteger.valueOf(10007);
  while(sc.hasNext()){
   //用BigInteger的modPow即可。
   BigInteger a = sc.nextBigInteger();
   BigInteger b = sc.nextBigInteger();
       
   System.out.println(a.modPow(b, mod));
  }

 }

}

留言

熱門文章