Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Pecnum {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int t = sc.nextInt();
- while (t-- > 0) {
- int a = sc.nextInt(), n = sc.nextInt();
- long num = (long) Math.pow(a, n);
- int sum = 0;
- while (num > 0) {
- sum += num % 10;
- num = num / 10;
- }
- System.out.println(sum);
- }
- sc.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement