본문 바로가기
python-algorithm

백준 24267 알고리즘 수업 - 알고리즘의 수행 시간 6

by 무적김두칠 2023. 1. 3.

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

 

24267번: 알고리즘 수업 - 알고리즘의 수행 시간 6

오늘도 서준이는 알고리즘의 수행시간 수업 조교를 하고 있다. 아빠가 수업한 내용을 학생들이 잘 이해했는지 문제를 통해서 확인해보자. 입력의 크기 n이 주어지면 MenOfPassion 알고리즘 수행

www.acmicpc.net

 

1
2
3
4
5
6
7
8
9
10
11
from math import factorial
if __name__ == '__main__':
    cnt = 0
    n = int(input())
    if n>=3:
        print(int(factorial(n)/(factorial(n-3)*factorial(3))))
    else:
        print(0)
    print(3)
 
 
cs

반복문 해석하면 n개중에 3개뽑는것과 같죠(== n combination 3)
그리고 3중반복문 이므로 3도 출력합니다.

If you interpret the loop statement, it is the same as picking 3 out of n (== n combination 3)
And since it is a triple repetition statement, 3 is also output.

반응형

'python-algorithm' 카테고리의 다른 글

백준 16861 Harshad Numbers  (0) 2023.01.03
백준 23343 JavaScript  (0) 2023.01.03
백준 11328 Strfry  (0) 2023.01.02
백준 3512 Flat  (0) 2022.12.31
백준 26264 빅데이터? 정보보호!  (0) 2022.12.30

댓글