백준 #1009번 분산처리

jhj·2025년 1월 18일

백준 JAVA

목록 보기
550/583
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int ans = 1;
			for(int j = 0; j < b; j++) {
				ans = (ans * a) % 10;
			}
			
			if(ans == 0) {
				System.out.println("10");
			}else {
				System.out.println(ans);
			}
		}
		sc.close();
	}
}
profile
개발자를 꿈꾸는

0개의 댓글