백준 1009 - 브론즈2 - Python

정답 코드

import sys input = lambda: sys.stdin.readline().rstrip() t = int(input()) for _ in range(t): a,b = map(int,input().split()) rec = [ [], [1], [2,4,8,6], [3,9,7,1], [4,6], [5], [6], [7,9,3,1], [8,4,2,6], [9,1] ] fina = a % 10 if fina == 0: print(10) else: print(rec[fina][(b - 1) % len(rec[fina])]) # 제출 번호 : 95378630, 메모리 : 32412, 시간 : 36

풀이과정

a^b의 1의 자리를 구하는 문제로서 a의 1의 자리에 계속하여 a가 곱해지는 경우 1의 자리끼리 곱해지는 것만을 고려하면되고, 이에 따라 규칙적으로 1의 자리가 변화하기에 규칙에 따라 처리하면 되는 문제이다.

비고

1. 오답

import sys input = lambda: sys.stdin.readline().rstrip() t = int(input()) for _ in range(t): a,b = map(int,input().split()) print(str(a**b)[-1])

배짱있게 틀렷당

2.

2에e승/e에2승/2에2승/e에e승/2에e승/e에2승/2에2승/e에e승/2에e승/e에2승/2에2승/e에e승/2에e승/e에2승/2에2승/e에e승