There are 15 hunters in one locality. Teams of 3 people are formed between them, so that in
during the 7 days of the hunt, no participant should be with any of those with
who has been on the team before. Determine the composition of the teams for the 7 days.
Can someone give me an idea of how I could solve it?
Expand|Select|Wrap|Line Numbers
- #include <iostream>
- int n, p, v[20];
- using namespace std;
- int valid(int k)
- {
- if (k == p) return 1;
- return 0;
- }
- void show(int k)
- {
- for (int i = 1; i <= k; i++) cout << v[i] << " ";
- cout << endl;
- }
- void BK(int k)
- {
- for (int i = v[k - 1] + 1; i <= n; i++)
- {
- v[k] = i;
- if (valid(k))
- show(k);
- else
- BK(k + 1);
- }
- }
- int main()
- {
- cout << "n= "; cin >> n; cout << "p= "; cin >> p;
- BK(1);
- return 0;
- }