結果
問題 | No.314 ケンケンパ |
ユーザー |
![]() |
提出日時 | 2019-04-25 20:03:41 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 26 ms / 1,000 ms |
コード長 | 460 bytes |
コンパイル時間 | 1,188 ms |
コンパイル使用メモリ | 158,324 KB |
実行使用メモリ | 73,808 KB |
最終ジャッジ日時 | 2024-11-21 10:29:14 |
合計ジャッジ時間 | 2,011 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h>using namespace std;int N;long long memo[1000009][3][3];long long mod=1000000007;int main() {cin >> N;if(N==1){cout << 1 << endl; return 0;}memo[2][1][1]=1;memo[2][1][0]=1;for(int i=3;i<=N;i++){memo[i][1][1]=memo[i-1][0][1];memo[i][1][0]=(memo[i-1][1][1]+memo[i-1][0][1])%mod;memo[i][0][1]=memo[i-1][1][0];}long long ans=(memo[N][1][1]+memo[N][1][0]+memo[N][0][1])%mod;cout << ans << endl;}