[백준] 2553번 마지막 팩토리얼 수

거북이·2023년 3월 23일
0

백준[실버2]

목록 보기
57/81
post-thumbnail

💡문제접근

  • math라이브러리에 있는 factorial을 이용해서 팩토리얼 값을 구한 다음 0이 아닌 가장 낮은 수를 구해주었다.

💡코드(메모리 : 33376KB, 시간 : 140ms)

import math
import sys
input = sys.stdin.readline

N = int(input())

res = str(math.factorial(N))
while True:
    res = res[::-1]
    for i in res:
        if i == "0":
            continue
        else:
            print(i)
            sys.exit(0)

💡소요시간 : 15m

0개의 댓글