백준 / 1009번 / 분산처리 / Python / 시간복잡도
2023. 12. 31. 14:25
📚문제 📝풀이 # 1009번 분산처리 t=int(input()) for _ in range(t): a,b=map(int,input().split()) print((a**b)%10) 처음에 이렇게 풀어줬을 때는 시간초과에 걸려버려서 오답... b가 10,000까지 있어서 파이썬에서도 꽤 큰 수를 연산해야해서 1초는 넘게 된다 # 1009번 분산처리 t = int(input()) answer =[] for _ in range(t): a,b = map(int,input().split()) b %= 4 if b%4==0: b=4 s = a**b if s%10 ==0: answer.append(10) else: answer.append(s%10) for i in answer: print(i) 다음은 a의 b승에 ..