fork(1) download
  1.  
  2.  
  3. import java.math.BigInteger;
  4. import java.util.Scanner;
  5.  
  6. public class Main{
  7.  
  8. public static void main(String[] args) {
  9. Scanner sc = new Scanner(System.in);//object create for taken input from user;
  10. BigInteger x,y,n,res;// declare x,y,n,res in BigInteger data type for large number calculation;
  11. int test;
  12. test=sc.nextInt();//Taken testcase for this problem;
  13. while(test-->0)//if testcase taken input then it's break;
  14. {
  15. x=BigInteger.valueOf(sc.nextInt());//taken input of x;
  16. y=BigInteger.valueOf(sc.nextInt());//taken input of y;
  17. n=BigInteger.valueOf(sc.nextInt());//taken input of n;
  18. res=x.modPow(y, n);// pow(x,y)%n operation are perform;
  19. System.out.println(res);//final result are print;
  20. }
  21.  
  22. }
  23.  
  24. }
  25.  
Success #stdin #stdout 0.14s 322368KB
stdin
2 
2 3 5 
2 2147483647 13 
0
stdout
3
11