제출 #1369836

#제출 시각아이디문제언어결과실행 시간메모리
1369836pandaa73Balanced Integer (CCO25_day1problem3)C++20
컴파일 에러
0 ms0 KiB
>
using namespace std;

#define ff endl
#define lf "\n"
#define fi first
#define se second
#define _ << ' ' <<
#define all(x) begin(x),end(x)
#define rall(x) rbegin(x),rend(x)

#ifdef DEBUG

constexpr bool IS_DEBUG = 1;

#define infor(fmt, ...) do { print(stderr, fmt, ##__VA_ARGS__); } while(0)
#define infof(fmt, ...) do { println(stderr, fmt, ##__VA_ARGS__); } while(0)

#else

constexpr bool IS_DEBUG = 0;

#define infor(fmt, ...)
#define infof(fmt, ...)

#endif

using ll = long long;

using pll = pair<ll, ll>;
using pii = pair<int, int>;

template<typename... Args>
using vec = vector<Args...>;

mt19937 timmy_loves_gambling(73);

pll len_sum(ll x, int b) {
    ll len = 0;
    ll sum = 0;

    while(x > 0) {
        len += 1;
        sum += x % b;
        x /= b;
    }

    return {len, sum};
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int B; ll N; cin >> B >> N;

    for(;; ++N) {
        bool ok = 1;
        for(int b = 2; b <= B; ++b) {
            auto [len, sum] = len_sum(N, b);

            ok &= 2 * sum == len * (b - 1);
        }

        if(ok) break;
    }

    cout << N << lf;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp:1:1: error: expected unqualified-id before '>' token
    1 | >
      | ^
Main.cpp:30:13: error: 'pair' does not name a type
   30 | using pll = pair<ll, ll>;
      |             ^~~~
Main.cpp:31:13: error: 'pair' does not name a type
   31 | using pii = pair<int, int>;
      |             ^~~~
Main.cpp:34:13: error: 'vector' does not name a type
   34 | using vec = vector<Args...>;
      |             ^~~~~~
Main.cpp:36:1: error: 'mt19937' does not name a type
   36 | mt19937 timmy_loves_gambling(73);
      | ^~~~~~~
Main.cpp:38:1: error: 'pll' does not name a type; did you mean 'll'?
   38 | pll len_sum(ll x, int b) {
      | ^~~
      | ll
Main.cpp: In function 'int main()':
Main.cpp:52:5: error: 'ios' has not been declared
   52 |     ios::sync_with_stdio(0);
      |     ^~~
Main.cpp:53:5: error: 'cin' was not declared in this scope
   53 |     cin.tie(0); cout.tie(0);
      |     ^~~
Main.cpp:53:17: error: 'cout' was not declared in this scope
   53 |     cin.tie(0); cout.tie(0);
      |                 ^~~~
Main.cpp:60:31: error: 'len_sum' was not declared in this scope; did you mean 'enum'?
   60 |             auto [len, sum] = len_sum(N, b);
      |                               ^~~~~~~
      |                               enum