Advertisement
Galebickosikasa

Untitled

Apr 23rd, 2021
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. int kek (int n) {
  2. vector <int> a;
  3. while (n) {
  4. a.push_back (n % 3);
  5. n /= 3;
  6. }
  7. reverse (a.begin(), a.end());
  8. int last = a.back ();
  9. for (int k = 0; k < (3); ++k) {
  10. vector <int> cnt (3);
  11. for (auto& x: a) ++cnt[x];
  12. int f = 0;
  13. for (int i = 0; i < (3); ++i) {
  14. for (int j = 0; j < (3); ++j) {
  15. if (i == j) continue;
  16. f |= cnt[i] == cnt[j];
  17. }
  18. }
  19. if (f) a.push_back (last);
  20. else {
  21. int mn = inf;
  22. for (auto& x: cnt) chkmin (mn, x);
  23. for (int i = 0; i < (3); ++i) {
  24. if (cnt[i] == mn) a.push_back (i);
  25. }
  26. }
  27. }
  28. reverse (a.begin(), a.end());
  29. int ans = 0;
  30. int p = 1;
  31. for (int i = 0; i < ((int)a.size()); ++i) {
  32. ans += a[i] * p;
  33. p *= 3;
  34. }
  35. return ans;
  36. }
  37.  
  38. signed main () {
  39. ios_base::sync_with_stdio (false);
  40. cin.tie (nullptr);
  41. for (int i = (71); i < (10000); ++i) {
  42. int x = kek (i);
  43. if (x % 2 == 0 && x % 6) {
  44. cout << i << '\n';
  45. break;
  46. }
  47. }
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement