在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
DescriptionGiven A,B,C, You should quickly calculate the result of A^B mod C. (1<=A,B,C<2^63). InputThere are multiply testcases. Each testcase, there is one line contains three integers A, B and C, separated by a single space. OutputFor each testcase, output an integer, denotes the result of A^B mod C. Sample Input3 2 4 2 10 1000 Sample Output1 24 1 import java.util.Scanner; 2 import java.math.BigInteger; 3 public class Main { 4 public static void main(String[] args) { 5 Scanner scan = new Scanner(System.in); 6 while(scan.hasNext()){ 7 BigInteger a = scan.nextBigInteger(); 8 BigInteger b = scan.nextBigInteger(); 9 BigInteger c = scan.nextBigInteger(); 10 System.out.println(a.modPow(b,c));//大整数乘方和取模 11 } 12 } 13 }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论