728x90
1009번: 분산처리
입력의 첫 줄에는 테스트 케이스의 개수 T가 주어진다. 그 다음 줄부터 각각의 테스트 케이스에 대해 정수 a와 b가 주어진다. (1 ≤ a < 100, 1 ≤ b < 1,000,000)
www.acmicpc.net
T=int(input())
result=[]
for i in range(T):
a,b=map(int,input().split())
a=a%10
if a==1 or a==5 or a==6:
result.append(a)
elif a==0:
result.append(10)
else:
if a==9:
if b%2==0:
result.append(1)
else:
result.append(9)
elif a==4:
if b%2==0:
result.append(6)
else:
result.append(4)
elif a==2:
if b%4==1:
result.append(2)
elif b%4==2:
result.append(4)
elif b%4==3:
result.append(8)
else:
result.append(6)
elif a==3:
if b%4==1:
result.append(3)
elif b%4==2:
result.append(9)
elif b%4==3:
result.append(7)
else:
result.append(1)
elif a==7:
if b%4==1:
result.append(7)
elif b%4==2:
result.append(9)
elif b%4==3:
result.append(3)
else:
result.append(1)
elif a==8:
if b%4==1:
result.append(8)
elif b%4==2:
result.append(4)
elif b%4==3:
result.append(2)
else:
result.append(6)
for i in range(T):
print(result[i])
반응형
'전.py' 카테고리의 다른 글
백준 5532 방학 숙제 (0) | 2020.12.16 |
---|---|
백준 1003 피보나치 함수 (0) | 2020.12.16 |
백준 2455 지능형 기차 (0) | 2020.12.16 |
백준 1094 막대기 (0) | 2020.12.16 |
백준 1966 프린터 큐 (0) | 2020.12.16 |