結果
問題 | No.314 ケンケンパ |
ユーザー |
![]() |
提出日時 | 2017-08-22 14:41:55 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 1,000 ms |
コード長 | 824 bytes |
コンパイル時間 | 985 ms |
コンパイル使用メモリ | 55,596 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-15 04:21:30 |
合計ジャッジ時間 | 1,201 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <iostream>using namespace std;long long memo[3]={1,1,1};//memo={kenPa,kenKen,paKen}, n=4long long kp, kk, pk, ans;int n;long long dp(){switch(n){case 1:ans = 1;break;case 2:ans = 2;break;case 3:ans = 2;break;case 4:ans = 3;break;default:for(int i=4; i<n; i++){kp = memo[0];kk = memo[1];pk = memo[2];memo[0] = (kk+pk)%1000000007;memo[1] = pk;memo[2] = kp;}ans = (memo[0]+memo[1]+memo[2])%1000000007;break;}return ans;}int main(){cin >> n;cout << dp() << endl;return 0;}