minyeamer
Minystory
minyeamer
edit settings
전체 방문자
오늘
어제
  • Category List (104)
    • Books (5)
      • Book Reviews (1)
      • Paper Reviews (4)
    • Life (4)
      • Blog (3)
      • Item Reviews (0)
      • Thoughts (1)
    • Study (37)
      • 2022 (3)
      • AI SCHOOL (34)
      • References (0)
    • Tech (58)
      • Algorithm (47)
      • Projects (9)
      • Python (2)

Blog Menu

  • Home
  • Notice
  • Tags
  • Guest

Popular Posts

Recent Comments

Recent Posts

hELLO
minyeamer

Minystory

Tech/Algorithm

[백준 1676] 팩토리얼 0의 개수 (Python)

2022. 8. 16. 12:41

문제 링크

https://www.acmicpc.net/problem/1676

 

1676번: 팩토리얼 0의 개수

N!에서 뒤에서부터 처음 0이 아닌 숫자가 나올 때까지 0의 개수를 구하는 프로그램을 작성하시오.

www.acmicpc.net

문제 해설

Idea

  • Math
  • 팩토리얼 수를 구하고 문자열로 변환해 연속되는 0의 개수를 출력

Data Size

  • N: 0 <= int <= 500

해설 코드

from math import factorial
import re

N = int(input())
zeros = re.findall('0+', str(factorial(N)))
if zeros:
    print(len(zeros[-1]))
else:
    print(0)
저작자표시 (새창열림)

'Tech > Algorithm' 카테고리의 다른 글

[프로그래머스]n진수 게임 (Python)  (0) 2022.08.16
[백준 1697] 숨바꼭질 (Python)  (0) 2022.08.16
[백준 1541] 잃어버린 괄호 (Python)  (0) 2022.08.16
[백준 1389] 케빈 베이컨의 6단계 법칙 (Python)  (0) 2022.08.16
[백준 5430] AC (Python)  (0) 2022.08.15
    'Tech/Algorithm' 카테고리의 다른 글
    • [프로그래머스]n진수 게임 (Python)
    • [백준 1697] 숨바꼭질 (Python)
    • [백준 1541] 잃어버린 괄호 (Python)
    • [백준 1389] 케빈 베이컨의 6단계 법칙 (Python)
    minyeamer
    minyeamer
    Better than Yesterday

    티스토리툴바