結果
| 問題 |
No.524 コインゲーム
|
| コンテスト | |
| ユーザー |
femto
|
| 提出日時 | 2017-06-03 00:03:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 699 bytes |
| コンパイル時間 | 1,595 ms |
| コンパイル使用メモリ | 168,228 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-22 03:40:08 |
| 合計ジャッジ時間 | 2,584 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 WA * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[32][2];
int N;
ll f(int n) {
memset(dp, 0, sizeof dp);
dp[0][1] = 1;
for(int i = 0; i < 31; i++) {
for(int j = 0; j < 2; j++) {
if(dp[i][j] == 0) continue;
int num = (i == n) ? 1 : (N >> i & 1);
for(int k = 0; k < 2; k++) {
int nj = 0;
if(j) {
nj = num >= k;
}
else {
nj = num > k;
}
dp[i + 1][nj] += dp[i][j];
}
}
}
return dp[31][1];
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N;
for(int i = 0; i < 31; i++) {
if((1 << i) > N) continue;
ll res = f(i);
if(res % 2) {
cout << "O" << endl;
return 0;
}
}
cout << "X" << endl;
}
femto