結果
問題 | No.314 ケンケンパ |
ユーザー |
![]() |
提出日時 | 2017-08-22 14:27:53 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 810 bytes |
コンパイル時間 | 423 ms |
コンパイル使用メモリ | 55,672 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-15 04:21:28 |
合計ジャッジ時間 | 1,152 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 7 WA * 10 |
ソースコード
#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];break;}return ans;}int main(){cin >> n;cout << dp() << endl;return 0;}