結果
問題 | No.524 コインゲーム |
ユーザー |
![]() |
提出日時 | 2020-03-22 19:23:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 758 bytes |
コンパイル時間 | 1,998 ms |
コンパイル使用メモリ | 166,392 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-25 19:24:52 |
合計ジャッジ時間 | 3,314 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define sz(x) int(x.size()) using namespace std; typedef long long ll; const int INF = 1e8; // const ll INF = 1LL << 60; typedef pair<int, int> P; int main() { ll N; cin >> N; // 桁ごとに xor を計算する // for (ll i = 1; i <= N; i++) { // ans ^= i; // } N++; ll ans = 0; for (int i = 0; i < 50; i++) { ll loop = (1LL << (i + 1)); ll cnt = (N / loop) * (loop / 2); cnt += max(0LL, (N % loop) - (loop / 2)); if (cnt % 2 == 1) { ans += 1LL << i; } } // cout << ans << endl; if (ans != 0) { cout << "O" << endl; } else { cout << "X" << endl; } }