From 9a79dbe900e586bcb3098f42d8b00db5de7080be Mon Sep 17 00:00:00 2001 From: yenru0 Date: Wed, 2 Jul 2025 11:17:56 +0900 Subject: [PATCH] complete 24783.cpp --- storage/zeta/cpp/completed/24783.cpp | 51 ++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 storage/zeta/cpp/completed/24783.cpp diff --git a/storage/zeta/cpp/completed/24783.cpp b/storage/zeta/cpp/completed/24783.cpp new file mode 100644 index 0000000..dbc25be --- /dev/null +++ b/storage/zeta/cpp/completed/24783.cpp @@ -0,0 +1,51 @@ +#include +#include +#include +#include + + +std::vector get_possible_numbers(uint16_t a, uint16_t b) { + std::vector v; + + v.push_back(a + b); + if (a > b) { + v.push_back(a - b); + } else { + v.push_back(b - a); + } + + if (a <= 10000 / b) { + v.push_back(a * b); + } + + if (a % b == 0) { + v.push_back(a / b); + } + if (b % a == 0) { + v.push_back(b / a); + } + + return v; +} + +bool is_possible_to_make(uint16_t a, uint16_t b, uint16_t c) { + auto nums = get_possible_numbers(a, b); + return std::find(nums.begin(), nums.end(), c) != nums.end(); +} + + +int32_t main() { + std::cin.tie(0); + std::cout.tie(0); + std::ios_base::sync_with_stdio(false); + + std::size_t t; + std::cin >> t; + uint16_t a, b, c; + for (std::size_t i = 0; i < t; i++) { + std::cin >> a >> b >> c; + std::cout << (is_possible_to_make(a, b, c) ? "Possible" : "Impossible") << std::endl; + } + + return 0; +} \ No newline at end of file