PRINT THE K'TH DIGIT FROM RIGHT OF A^B
import java.util.*;
import java.lang.*;
import java.io.*;
class GFG {
public static void main (String[] args) {
Scanner s=new Scanner(System.in);
int t=s.nextInt();
for(int i=0;i<t;i++)
{
int a=s.nextInt();
int b=s.nextInt();
int k=s.nextInt();
int p=(int)Math.pow(a,b);
int count=0;
while(p>0 && count<k)
{
int rem=p%10;
count++;
if(count==k)
System.out.println(rem);
p=p/10;
}
}
}
}
Comments
Post a Comment