import java.util.Scanner;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) {
BigInteger a,p,m;
int i,b;
Scanner input=new Scanner(System.in);
while(input.hasNext())
{
b=input.nextInt();
if(b==0)
{
break;
}
else
{
for(i=0;i<b;i++)
{
a=input.nextBigInteger();
p=input.nextBigInteger();
m=input.nextBigInteger();
System.out.println(a.modPow(p,m));
}
}
}
}
}
import java.math.BigInteger;
public class Main {
public static void main(String[] args) {
BigInteger a,p,m;
int i,b;
Scanner input=new Scanner(System.in);
while(input.hasNext())
{
b=input.nextInt();
if(b==0)
{
break;
}
else
{
for(i=0;i<b;i++)
{
a=input.nextBigInteger();
p=input.nextBigInteger();
m=input.nextBigInteger();
System.out.println(a.modPow(p,m));
}
}
}
}
}
0 comments:
Post a Comment