Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
591 B
0
Indexable
Never
#include <iostream>

using namespace std;

int n, k;
int dem = 0;
int nguon, dich, trunggian;

void THAP(int i, int& nguon, int& dich, int& trunggian) {
	//cout << nguon << " " << dich << " " << trunggian;
	if (dem == k) return;
	else {
		if (i == 1) {
			dem++;
			nguon--;
			dich++;
		}
		else
		{
			THAP(i - 1, nguon, trunggian, dich);
			THAP(1, nguon, dich, trunggian );
			THAP(i - 1, trunggian, dich, nguon);
		}
	}
}

int main() {
	cin >> n >> k;
	nguon = n; dich = 0; trunggian = 0;
	THAP(n, nguon, dich, trunggian);
	cout << nguon << " " << dich << " " << trunggian;
	return 0;
}