結果

問題 No.314 ケンケンパ
ユーザー Asdf_QwertyZAsdf_QwertyZ
提出日時 2018-06-05 23:42:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 46 ms / 1,000 ms
コード長 650 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 32,856 KB
実行使用メモリ 26,384 KB
最終ジャッジ日時 2023-09-12 22:37:18
合計ジャッジ時間 1,657 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

constexpr int mod = 1000000007;

int N;
int dp[1000001][2][3];

int main()
{
  scanf( "%d", &N );

  dp[0][0][0] = 1;

  rep( i, N ) rep( j, 2 ) rep( k, 3 )
  {
    if( !j && k+1 < 3 )
      dp[i+1][0][k+1] = (dp[i+1][0][k+1]+dp[i][j][k]) % mod;
    if( j )
      dp[i+1][0][1] = (dp[i+1][0][1]+dp[i][j][k]) % mod;  

    if( !j && i )
      dp[i+1][1][0] = (dp[i+1][1][0]+dp[i][j][k]) % mod;
  }

  int ans = 0;

  rep( j, 2 ) rep( k, 3 )
    ans = (ans + dp[N][j][k]) % mod;

  printf( "%d\n", ans );
  
  return 0;
}
0