結果

問題 No.314 ケンケンパ
ユーザー kyawashellkyawashell
提出日時 2018-04-09 11:51:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 75 ms / 1,000 ms
コード長 969 bytes
コンパイル時間 864 ms
コンパイル使用メモリ 100,604 KB
実行使用メモリ 26,744 KB
最終ジャッジ日時 2023-09-09 03:24:15
合計ジャッジ時間 2,312 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
26,596 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 10 ms
5,768 KB
testcase_18 AC 37 ms
14,536 KB
testcase_19 AC 75 ms
26,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

ll n;

ll dp[1 << 20][3];
ll mod = 1e9+7;

int main(){
    cin >> n;

    dp[0][0] = 1;

    REP(i,n) {
        REP(j,3) {
            if(j != 2) {
                (dp[i + 1][j + 1] += dp[i][j]) %= mod;
            }
            if(j != 0) {
                (dp[i + 1][0] += dp[i][j]) %= mod;
            }
        }
    }
    ll ans = 0;
    REP(i,3) {
        (ans += dp[n][i]) %= mod;
    }
    cout << ans << endl;
    return 0;
}

0