문제) 재용이는 최신 컴퓨터 10대를 가지고 있다. 어느 날 재용이는 많은 데이터를 처리해야 될 일이 생겨서 각 컴퓨터에 1번부터 10번까지의 번호를 부여하고, 10대의 컴퓨터가 다음과 같은 방법으로 데이터들을 처리하기로 하였다.
1번 데이터는 1번 컴퓨터, 2번 데이터는 2번 컴퓨터, 3번 데이터는 3번 컴퓨터, ... ,
10번 데이터는 10번 컴퓨터, 11번 데이터는 1번 컴퓨터, 12번 데이터는 2번 컴퓨터, ...
총 데이터의 개수는 항상 ab개의 형태로 주어진다. 재용이는 문득 마지막 데이터가 처리될 컴퓨터의 번호가 궁금해졌다. 이를 수행해주는 프로그램을 작성하라.
package sw_study.bj1009;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
StringBuilder sb = new StringBuilder();
int test_case = sc.nextInt();
sc.nextLine();
int answer=0;
for(int t = 1; t <= test_case ; t++) {
int a = sc.nextInt();
int b = sc.nextInt();
sc.nextLine();
int[] num2= {6,2,4,8};
int[] num3= {1,3,9,7};
int[] num4= {6,4};
int[] num7= {1,7,9,3};
int[] num8= {6,8,4,2};
int[] num9= {1,9};
a=a%10;
if(b==0) {
answer=1;
}else if(a==1||a==5||a==6) {
answer= a;
}else if(a==0) {
answer=10;
}else if(a==2) {
int n=b%4;
answer=num2[n];
}else if (a==3) {
int n=b%4;
answer=num3[n];
}else if(a==4) {
int n=b%2;
answer=num4[n];
}else if(a==7) {
int n=b%4;
answer=num7[n];
}else if(a==8) {
int n=b%4;
answer=num8[n];
}else if(a==9) {
int n=b%2;
answer=num9[n];
}
sb.append(answer).append("\n");
}
System.out.print(sb.toString());
}
}