We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 73f1068 commit 08319f0Copy full SHA for 08319f0
Combination.cpp
@@ -0,0 +1,46 @@
1
+#include <cstdio>
2
+
3
+using namespace std;
4
5
+int sc, rc;
6
+bool sel[50010];
7
8
+// Take m stone(s) last n stone(s).
9
+void enum_combination(int n, int m)
10
+{
11
+ if (m == 0)
12
+ {
13
+ for (int i = 0; i < sc; i++)
14
15
+ if (sel[i])
16
17
+ printf("%d ", i);
18
+ }
19
20
+ printf("\n");
21
+ return;
22
23
24
+ if (n > m)
25
26
+ sel[sc - n - 1] = true;
27
+ enum_combination(n - 1, m - 1);
28
+ sel[sc - n - 1] = false;
29
+ enum_combination(n - 1, m);
30
31
+ else
32
33
34
35
36
37
+}
38
39
+int main()
40
41
+ scanf("%d%d", &sc, &rc);
42
+ sc += 2;
43
+ enum_combination(sc - 2, rc);
44
45
+ return 0;
46
0 commit comments