[알고리즘]/알고리즘

[알고리즘] 백준 1009번. 분산처리

쿠릉쿠릉 쾅쾅 2022. 2. 10. 02:24
728x90

 

 

백준1009번. 분산처리

https://www.acmicpc.net/problem/1009

 

1009번: 분산처리

입력의 첫 줄에는 테스트 케이스의 개수 T가 주어진다. 그 다음 줄부터 각각의 테스트 케이스에 대해 정수 a와 b가 주어진다. (1 ≤ a < 100, 1 ≤ b < 1,000,000)

www.acmicpc.net

 

 

📌 풀이

import java.util.Arrays;
import java.util.Scanner;

public  class Main {	

    public static void main (String[] args) {    
    	
    	Scanner sc = new Scanner(System.in);
    	
    	int T = sc.nextInt();
    	
    	for(int t=0; t<T; t++) {
    		int a = sc.nextInt();
    		
    		int b = sc.nextInt();

    		int tmp = a;
    		
    		for(int i=0; i<b-1; i++) {
    			a = tmp * a % 10;
    		}
    		
            a%=10;
            
    		if(a==0)
    			a=10;

    		System.out.println(a);
    	}
	
    }
}

 

728x90