Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int kek (int n) {
- vector <int> a;
- while (n) {
- a.push_back (n % 3);
- n /= 3;
- }
- reverse (a.begin(), a.end());
- int last = a.back ();
- for (int k = 0; k < (3); ++k) {
- vector <int> cnt (3);
- for (auto& x: a) ++cnt[x];
- int f = 0;
- for (int i = 0; i < (3); ++i) {
- for (int j = 0; j < (3); ++j) {
- if (i == j) continue;
- f |= cnt[i] == cnt[j];
- }
- }
- if (f) a.push_back (last);
- else {
- int mn = inf;
- for (auto& x: cnt) chkmin (mn, x);
- for (int i = 0; i < (3); ++i) {
- if (cnt[i] == mn) a.push_back (i);
- }
- }
- }
- reverse (a.begin(), a.end());
- int ans = 0;
- int p = 1;
- for (int i = 0; i < ((int)a.size()); ++i) {
- ans += a[i] * p;
- p *= 3;
- }
- return ans;
- }
- signed main () {
- ios_base::sync_with_stdio (false);
- cin.tie (nullptr);
- for (int i = (71); i < (10000); ++i) {
- int x = kek (i);
- if (x % 2 == 0 && x % 6) {
- cout << i << '\n';
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement