문제 링크: https://www.acmicpc.net/problem/11050
백준 정수론 및 조합론 7단계 - 11050번 이항 계수 1을 풀어보았다.
풀이: 이항계수를 구현하면 된다.
C++
#include <iostream>
using namespace std;
int fac(int a)
{
if(a==1||a==0) return 1;
else return a*fac(a-1);
}
int main()
{
int a,b;
cin>>a>>b;
cout<<fac(a)/fac(b)/fac(a-b);
}
Python
def fac(i):
if i==1 or i==0: return 1
else: return i*fac(i-1)
a,b=map(int,input().split())
res=fac(a)//fac(b)//fac(a-b)
print(res)
Java
'코테용 문제풀이 > 백준' 카테고리의 다른 글
다리 놓기 풀이 (0) | 2023.01.09 |
---|---|
이항 계수 2 풀이 (0) | 2023.01.09 |
최소공배수 풀이 (0) | 2023.01.09 |
링 풀이 (0) | 2023.01.09 |
검문 풀이 (0) | 2023.01.09 |