結果

問題 No.685 Logical Operations
ユーザー square1001square1001
提出日時 2018-05-29 18:11:32
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 897 bytes
コンパイル時間 581 ms
コンパイル使用メモリ 64,432 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-12 20:26:00
合計ジャッジ時間 3,239 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
using namespace std;
const unsigned mod = 1000000007;
unsigned long long N; unsigned dp[66][16]; bool vis[66][16];
unsigned solve(int digit, int fx, int fy, int f10, int f11) {
	if (digit == -1) return f10 && f11 ? 1 : 0;
	int h = fx + fy * 2 + f10 * 4 + f11 * 8;
	if (vis[digit][h]) return dp[digit][h];
	unsigned ret = solve(digit - 1, fx || ((N >> digit) & 1), fy || ((N >> digit) & 1), f10, f11);
	bool vx = fy == 1 || ((N >> digit) & 1);
	bool vy = fx == 1 || ((N >> digit) & 1);
	if (vy) ret += solve(digit - 1, fx || ((N >> digit) & 1), fy, 1, f11);
	if (vx) ret += solve(digit - 1, fx, fy || ((N >> digit) & 1), 1, f11);
	if (vx && vy && f10) ret += solve(digit - 1, fx, fy, 1, 1);
	while (ret >= mod) ret -= mod;
	vis[digit][h] = true;
	dp[digit][h] = ret;
	return ret;
}
int main() {
	cin >> N;
	int ret = solve(60, 0, 0, 0, 0);
	cout << ret / 2 << '\n';
	return 0;
}
0