結果

問題 No.1811 EQUIV Ten
ユーザー trineutron
提出日時 2022-01-14 22:03:55
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 684 bytes
コンパイル時間 3,106 ms
コンパイル使用メモリ 251,428 KB
実行使用メモリ 17,256 KB
最終ジャッジ日時 2024-11-20 10:26:06
合計ジャッジ時間 3,967 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>

using namespace std;
using namespace atcoder;

using mint = modint1000000007;

int main()
{
    int n;
    cin >> n;
    mint ans = 0;
    vector dp(n + 1, vector<mint>(8));
    dp.at(0).at(0) = 1;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 8; j++)
        {
            if (j == 5)
            {
                ans += dp.at(i).at(j) * mint(2).pow(n - i - 1);
            }
            else
            {
                dp.at(i + 1).at(2 * j % 8) += dp.at(i).at(j);
            }
            dp.at(i + 1).at((2 * j + 1) % 8) += dp.at(i).at(j);
        }
    }
    cout << ans.val() << endl;
    return 0;
}
0