P1618 三連擊(升級版)
阿新 • • 發佈:2022-02-07
// Problem: P1618 三連擊(升級版) // Contest: Luogu // URL: https://www.luogu.com.cn/problem/P1618 // Memory Limit: 125 MB // Time Limit: 1000 ms // User: Pannnn #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int a, b, c; cin >> a >> b >> c; vector<vector<int>> res; for (int i = 100; i <= 999; ++i) { int cnt[10] = { 0 }; vector<int> num(3); num[0] = i; if (num[0] * b % a != 0 || num[0] * c % a != 0) { continue; } num[1] = num[0] * b / a; num[2] = num[0] * c / a; for (int j = 0; j < 3; ++j) { string str = to_string(num[j]); for (char c : str) { ++cnt[c - '0']; } } bool flag = true; for (int j = 1; j < 10; ++j) { if (cnt[j] != 1 || cnt[0] != 0) { flag = false; break; } } if (flag) { res.push_back(num); } } if (res.size() == 0) { cout << "No!!!" << endl; } for (int i = 0; i < res.size(); ++i) { cout << res[i][0] << " " << res[i][1] << " " << res[i][2] << endl; } return 0; }