Given three numbers a,b,c. Calculate (a^b)mod c

only 3/10 cases passed stating as wrong answer. Is the logic not right?

public static void main(String args[]) {
Scanner s1=new Scanner(System.in);
int a=s1.nextInt();
int b=s1.nextInt();
int c=s1.nextInt();
double power=Math.pow(a,b);
int ans=(int)power%c;
System.out.print(ans);
}