1. Список говнокодов пользователя govnovmk123

    Всего: 1

  2. Си / Говнокод #29298

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    #include <stdio.h>
    
    #define int long long
    #define mx 1000000
    
    signed main(void) {
        int n;
        scanf("%lld", &n);
    
        if (n > mx) {
            printf("-1");
            return 0;
        }
    
        int x = n;
        int l = n;  // чашка с товаром
        int r = 0;  // другая чашка
        int w = 1;
        int c = 0;
    
        while (x != 0) {
            if (x % 3 == 0) {
                x /= 3;
            }
            else if (x % 3 == 1) {
                r += w;
                c++;
                x /= 3;
            }
            else { // x % 3 == 2
                l += w;
                c++;
                x = (x + 1) / 3;
            }
    
            w *= 3;
        }
    
        if (l > mx || r > mx)
            printf("-1");
        else
            printf("%lld", c);
    
        return 0;
    }

    #define int long long
    int x = n;
    int l = n; // чашка с товаром
    int r = 0; // другая чашка
    int w = 1;
    int c = 0;
    фортепиано

    govnovmk123, 19 Ноября 2026

    Комментарии (1)