Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
148244 于墨轩 猜数字 C++ Accepted 3 MS 284 KB 676 2026-02-10 13:47:29

Tests(1/1):


Code:

#include <iostream> using namespace std; int findTargetNumber(int a, int b, int c) { for (int x = 1000; x <= 9999; ++x) { if (x % a == 0 && (x + 1) % b == 0 && (x + 2) % c == 0) { return x; } } return -1; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int c; cin >> c; while (c--) { int a, b, c_val; cin >> a >> b >> c_val; int result = findTargetNumber(a, b, c_val); if (result != -1) { cout << result << '\n'; } else { cout << "Impossible\n"; } } return 0; }