結果

問題 No.685 Logical Operations
ユーザー PachicobuePachicobue
提出日時 2018-09-15 01:46:28
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 819 bytes
コンパイル時間 2,034 ms
コンパイル使用メモリ 202,804 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 08:57:15
合計ジャッジ時間 3,660 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr int SIZE = 60;
int main()
{
    ll N;
    std::cin >> N;
    if (N == 0) { return std::cout << 0 << std::endl, 0; }
    std::bitset<SIZE> b(N);
    std::vector<ll> dp(8, 0);
    dp[0] = 1;
    for (int i = SIZE - 1; i >= 0; i--) {
        const bool B = b[i];
        dp = {
            B ? 0 : dp[0],
            B ? 0 : dp[1],
            (dp[2] + (B ? dp[0] : dp[2])) % MOD,
            (2 * dp[3] + (B ? dp[1] + dp[2] : 0)) % MOD,
            (dp[4] + (B ? dp[0] : 0)) % MOD,
            (dp[5] + (B ? dp[1] : 0)) % MOD,
            (dp[4] + 3 * dp[6] + (B ? 2 * dp[2] : 0)) % MOD,
            (dp[5] + dp[6] + 4 * dp[7] + (B ? 2 * dp[3] : 0)) % MOD};
    }
    std::cout << (dp[3] + dp[7]) % MOD << std::endl;
    return 0;
}
0