結果
| 問題 |
No.314 ケンケンパ
|
| コンテスト | |
| ユーザー |
nxteru
|
| 提出日時 | 2018-06-05 21:41:18 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 1,000 ms |
| コード長 | 402 bytes |
| コンパイル時間 | 575 ms |
| コンパイル使用メモリ | 70,076 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-30 10:05:56 |
| 合計ジャッジ時間 | 1,338 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define M 1000000007
ll n;
ll dp[2][3];
int main(void){
cin>>n;
dp[0][0]=1;
for(int i=0;i<n;i++){
int u=(i+1)%2;
dp[u][0]=(dp[i%2][1]+dp[i%2][2])%M;
dp[u][1]=dp[i%2][0];
dp[u][2]=dp[i%2][1];
}
cout<<((dp[n%2][0]+dp[n%2][1])%M+dp[n%2][2])%M<<endl;
}
nxteru