結果

問題 No.1811 EQUIV Ten
ユーザー ぷらぷら
提出日時 2022-01-14 22:08:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 172 ms / 2,000 ms
コード長 1,097 bytes
コンパイル時間 2,139 ms
コンパイル使用メモリ 199,032 KB
実行使用メモリ 15,860 KB
最終ジャッジ日時 2023-08-12 19:59:33
合計ジャッジ時間 4,892 ms
ジャッジサーバーID
(参考情報)
judge14 / judge8
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 142 ms
13,932 KB
testcase_12 AC 153 ms
14,540 KB
testcase_13 AC 167 ms
15,536 KB
testcase_14 AC 172 ms
15,812 KB
testcase_15 AC 170 ms
15,860 KB
testcase_16 AC 2 ms
4,384 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,384 KB
testcase_20 AC 8 ms
4,380 KB
testcase_21 AC 7 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 56 ms
7,696 KB
testcase_24 AC 11 ms
4,380 KB
testcase_25 AC 2 ms
4,384 KB
testcase_26 AC 45 ms
6,720 KB
testcase_27 AC 4 ms
4,384 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 137 ms
13,440 KB
testcase_31 AC 5 ms
4,384 KB
testcase_32 AC 12 ms
4,404 KB
testcase_33 AC 13 ms
4,380 KB
testcase_34 AC 130 ms
12,932 KB
testcase_35 AC 44 ms
6,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

constexpr int mod = 1000000007;

long long modpow(long long a,long long b) {
    if(b < 0) {
        return 0;
    }
    long long ans = 1;
    while(b) {
        if(b & 1) {
            (ans *= a) %= mod;
        }
        (a *= a) %= mod;
        b /= 2;
    }
    return ans;
}

int dp[200001][1 << 4];

int main() {
    int N;
    cin >> N;
    for(int i = 0; i < 16; i++) {
        dp[4][i] = 1;
    }
    dp[4][10] = 0;
    long long ans = modpow(2,N-4);
    for(int i = 4; i < N; i++) {
        for(int j = 0; j < 16; j++) {
            if(j/2 == 10) {
                ans += modpow(2,N-i-1)*dp[i][j]%mod;
                ans %= mod;
            }
            else {
                dp[i+1][j/2] += dp[i][j];
                dp[i+1][j/2] %= mod;
            }
            if(j/2+8 == 10) {
                ans += modpow(2,N-i-1)*dp[i][j]%mod;
                ans %= mod;
            }
            else {
                dp[i+1][j/2+8] += dp[i][j];
                dp[i+1][j/2+8] %= mod;
            }
        }
    }
    cout << ans << endl;
}
0