From 10f157f42e9b08cd538c552735664da735f89f1a Mon Sep 17 00:00:00 2001 From: InigoGutierrez Date: Mon, 1 Jun 2020 21:22:36 +0200 Subject: =?UTF-8?q?192,=20Por=203=20o=20m=C3=A1s=205,=20superando=20tiempo?= =?UTF-8?q?=20m=C3=A1ximo.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- c/192_por3oMas5.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 c/192_por3oMas5.cpp 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 + +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; +} -- cgit v1.2.1