알고리즘
백준 17213번 과일 서리 C++
영춘권의달인
2023. 3. 24. 12:40
https://www.acmicpc.net/problem/17213
17213번: 과일 서리
민건이네 과일 농장은 N가지 종류의 과일을 재배하는 중이다. 평소 민건이에게 앙심을 품고 있던 지환이는 민건이를 골탕 먹이기 위하여 민건이네 과일 농장에서 과일들을 훔치기로 다짐했다.
www.acmicpc.net
중복조합
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <limits.h>
using namespace std;
using int64 = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int64 n, m;
cin >> n >> m;
m -= n;
int64 x = 1;
int64 y = 1;
int64 xStart = n + m - 1;
int64 yStart = min(n - 1, m);
for (int i = 0; i < yStart; i++) {
x *= xStart - i;
y *= yStart - i;
}
cout << x / y;
}