diff options
Diffstat (limited to 'c/192_por3oMas5.cpp')
-rw-r--r-- | c/192_por3oMas5.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/c/192_por3oMas5.cpp b/c/192_por3oMas5.cpp new file mode 100644 index 0000000..d8e3455 --- /dev/null +++ b/c/192_por3oMas5.cpp @@ -0,0 +1,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; +} |