結果

問題 No.314 ケンケンパ
ユーザー hogeover30hogeover30
提出日時 2015-12-07 06:18:10
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 17 ms / 1,000 ms
コード長 511 bytes
コンパイル時間 471 ms
コンパイル使用メモリ 24,212 KB
実行使用メモリ 13,552 KB
最終ジャッジ日時 2023-10-12 19:46:28
合計ジャッジ時間 1,197 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
13,436 KB
testcase_01 AC 0 ms
4,348 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 0 ms
4,348 KB
testcase_05 AC 0 ms
4,356 KB
testcase_06 AC 0 ms
4,348 KB
testcase_07 AC 0 ms
4,352 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 0 ms
4,352 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,352 KB
testcase_17 AC 3 ms
4,348 KB
testcase_18 AC 8 ms
7,316 KB
testcase_19 AC 17 ms
13,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
const unsigned int mod=1e9+7;
unsigned int dp[1000010][3];

int main()
{
    int i, n;
    scanf("%d", &n);
    dp[0][0]=1;
    for(i=1;i<=n;++i) {
        if ((dp[i][1]+=dp[i-1][0])>=mod) dp[i][1]-=mod;
        if ((dp[i][2]+=dp[i-1][1])>=mod) dp[i][2]-=mod;
        if ((dp[i][0]+=dp[i-1][1])>=mod) dp[i][0]-=mod;
        if ((dp[i][0]+=dp[i-1][2])>=mod) dp[i][0]-=mod;
    }
    int res=0;
    for(i=0;i<3;++i) if ((res+=dp[n][i])>=mod) res-=mod;
    printf("%d\n", res);
    return 0;
}

0