Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 |
Tags
- c++ 코테
- ML
- 플러터
- 오블완
- 코딩테스트준비
- 코테 파이썬
- 안드로이드
- 코테
- 99클럽
- 개발자 취업
- 알고리즘
- react
- 코딩테스트 준비
- 라라벨
- 뷰
- flutter getx
- vue
- C++
- 항해99
- Python
- 파이썬
- 파이썬 코테
- 개발자취업
- til
- 티스토리챌린지
- Laravel
- DP
- 백준
- 코딩테스트
- Flutter
Archives
- Today
- Total
잡다로그
[Python/코테] 백준 2407 조합 본문
2407 조합
문제 및 조건 설명: https://www.acmicpc.net/problem/2407

알고리즘 설계
💡idea.
조합 공식을 구현한다.

🎲step.
1. 팩토리얼(!) 연산을 구현하기 위해 재귀 혹은 반복문을 사용한다.
2. 수학 라이브러리를 사용한다.
알고리즘 구현
재귀(반복) 사용
n, m = map(int, input().split())
def factorial(n):
if n > 1:
return n * factorial(n-1)
else:
return 1
print(factorial(n) // (factorial(n-m) * factorial(m)))
라이브러리 사용
* 코드 출처: https://star7sss.tistory.com/285
from math import comb
n, m = map(int, input().split())
print(comb(n, m))
'Algorithm' 카테고리의 다른 글
| [Python/코테] 백준 20922 겹치는 건 싫어 (0) | 2024.04.02 |
|---|---|
| [Python/코테] 백준 14888 연산자 끼워넣기 (1) | 2024.04.01 |
| [Python/코테] 백준 10158 개미 (1) | 2024.03.29 |
| [Python/코테] 2024 Kakao Winter Internship - 2. 도넛과 막대 그래프 (0) | 2024.03.27 |
| [Python/코테] 2024 Kakao Winter Internship - 1. 가장 많이 받은 선물 (0) | 2024.03.26 |
Comments