ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • BOJ15650: N과 M (2)
    BOJ 2024. 2. 1. 00:21
    #include <bits/stdc++.h>
    using namespace std;
    int n, m;
    vector<int> a;
    int main(void) {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cin >> n >> m;
        
        for (int i = 0; i < m; i++) a.push_back(0);
        for (int i = 0; i < n - m; i++) a.push_back(1);
        do {
            for (int i = 0; i < n; i++) {
                if (a[i] == 0) cout << i + 1 << ' ';
            }
            cout << '\n';
        } while (next_permutation(a.begin(), a.end()));
    }
Designed by Tistory.