結果
問題 |
No.314 ケンケンパ
|
ユーザー |
![]() |
提出日時 | 2016-08-30 00:06:49 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 18 ms / 1,000 ms |
コード長 | 818 bytes |
コンパイル時間 | 780 ms |
コンパイル使用メモリ | 59,328 KB |
実行使用メモリ | 26,848 KB |
最終ジャッジ日時 | 2024-11-14 06:52:30 |
合計ジャッジ時間 | 1,321 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <iostream> #include <algorithm> #include <vector> #include <cstdio> using namespace std; typedef long long ll; #define rep(i,n) for(int i=0;i<(n);i++) const int mod = 1e9 + 7; //dp[i][j] := i番目まで考えて、j回連続ケン ll dp[1000010][3]; int main(void){ int n; cin >> n; rep(i, n)rep(j, 3)dp[i][j] = 0; dp[1][1] = 1;//ケン for (int i = 1; i < n; ++i){ for (int j = 0; j < 3; ++j){ if(j == 0){//*パー (dp[i + 1][1] += dp[i][0]) %= mod;//ケン }else if(j == 1){//*パー ケン (dp[i + 1][0] += dp[i][1]) %= mod;//パー (dp[i + 1][2] += dp[i][1]) %= mod;//ケン }else if(j == 2){//*パー ケン ケン (dp[i + 1][0] += dp[i][2]) %= mod;//パー } } } ll ans = 0; rep(i, 3){ (ans += dp[n][i]) % mod; } printf("%lld\n", ans % mod); return 0; }