Notice
Recent Posts
Recent Comments
Link
관리 메뉴

one by one ◼◻◼◻

백준 1009, 분산처리 본문

코딩문제

백준 1009, 분산처리

JihyunLee 2022. 6. 16. 12:16

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import sys
= int(sys.stdin.readline())
 
for _ in range(N):
    items = list(map(int, sys.stdin.readline().split()))
 
    a,b = items[0]%10, items[1]
    temp = a
    last_part = [a]
    if a == 0:
        print(10)
        continue
 
    while True:
        temp*= a
        if len(last_part)!=1 and temp%10 == a:
            break
        else:
            last_part.append(temp%10)
 
    
    loop_len = len(last_part)
    print(last_part[b%loop_len-1])
cs
Comments