結果
| 問題 |
No.314 ケンケンパ
|
| コンテスト | |
| ユーザー |
tanutarou730
|
| 提出日時 | 2017-07-23 04:24:00 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 17 ms / 1,000 ms |
| コード長 | 716 bytes |
| コンパイル時間 | 1,857 ms |
| コンパイル使用メモリ | 158,064 KB |
| 実行使用メモリ | 15,104 KB |
| 最終ジャッジ日時 | 2024-10-09 10:25:43 |
| 合計ジャッジ時間 | 2,707 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;
int dp[1000001][3];
int main(void) {
//ios_base::sync_with_stdio(false);
//cin.tie(0);
ll n;
cin >> n;
dp[0][0] = 1;
for(int i=1; i<=n; i++){
dp[i][0] = dp[i-1][1] + dp[i-1][2];
dp[i][1] = dp[i-1][0];
dp[i][2] = dp[i-1][1];
for(int j=0; j<3; j++){
dp[i][j] %= MOD;
}
}
/*
for(int i=0; i<=n; i++){
for(int j=0; j<3; j++){
printf("%d ", dp[i][j]);
}
puts("");
}
*/
ll ans = dp[n][0];
ans += dp[n][1];
ans %= MOD;
ans += dp[n][2];
ans %= MOD;
cout << ans << endl;
return 0;
}
tanutarou730