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