1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5;
typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi;
#define rep(i, a, n) for (int i = a; i < n; ++i) #define per(i, a, n) for (int i = n - 1; i >= a; --i) #define fi first #define se second #define endl '\n' #define all(x) x.begin(), x.end() #define pb push_back #define np next_permutation #define mp make_pair
int vis[maxn];
bool check(int num) { int a[6]; int num1 = 2 * num; int num2 = 3 * num; if (num2 >= 999) return false; rep(i, 0, 3) { a[i] = num1 % 10; num1 /= 10; } rep(i, 3, 6) { a[i] = num2 % 10; num2 /= 10; } rep(i, 0, 6) { if (vis[a[i]]) return false; vis[a[i]] = 1; } return true; }
int main() { ios::sync_with_stdio(false); rep(i, 1, 3 + 1) { vis[i] = 1; rep(j, 1, 9 + 1) { if (vis[j]) continue; vis[j] = 1; rep(k, 1, 9 + 1) { vis[i] = vis[j] = 1; if (vis[k]) continue; vis[k] = 1; int temp = 100 * i + 10 * j + k; if (check(temp)) { cout << temp << " " << 2 * temp << " " << 3 * temp << endl; } memset(vis, 0, sizeof(vis)); } vis[j] = 0; } vis[i] = 0; } int n; cin >> n; }
|