結果

問題 No.524 コインゲーム
ユーザー femtofemto
提出日時 2017-06-03 00:03:35
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 699 bytes
コンパイル時間 1,379 ms
コンパイル使用メモリ 166,712 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 01:58:15
合計ジャッジ時間 2,362 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 WA -
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
4,348 KB
testcase_28 WA -
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 1 ms
4,348 KB
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 1 ms
4,348 KB
testcase_34 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0