結果
問題 |
No.685 Logical Operations
|
ユーザー |
![]() |
提出日時 | 2018-05-29 18:11:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 897 bytes |
コンパイル時間 | 517 ms |
コンパイル使用メモリ | 65,944 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-30 08:02:09 |
合計ジャッジ時間 | 1,582 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 WA * 14 |
ソースコード
#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; }