Algorithm/back_tracking
[Algo] c++ next_permutation으로 조합 구현하기
Mini_96
2024. 9. 6. 22:38
//25C7 구현
// N개의 요소를 가진 벡터 생성, 뒤에서 K개만 1로 설정
n = 25;
vector<int> v(n);
fill(v.end() - 7, v.end(), 1);
int cnt = 0;
do {
cnt++;
/*for (int i = 0; i < 25; ++i) {
if (v[i]) {
cout << i << " ";
}
}cout << "\n";*/
} while (next_permutation(v.begin(), v.end()));
cout << cnt; //480,700