aboutsummaryrefslogtreecommitdiff
path: root/c/192_por3oMas5.cpp
blob: d8e34553d19689d9697dacbb33a0fb684580221a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>

int sumN = 5;
int mulN = 3;

int solve(int input) {

	int result = 0;

	if (input == 1) {
		return 1;
	}

	if (input > 0 && input % mulN == 0) {
		result = solve(input / mulN);
	}

	if (!result) {
		if (input > sumN) {
			result = solve(input - sumN);
		}
	}

	return result;

}

int main() {
	int input;
	std::cin >> input;
	while (input != 0) {
		if (solve(input))
			std::cout << "SI\n";
		else
			std::cout << "NO\n";
		std::cin >> input;
	}
	return 0;
}