結果
問題 |
No.314 ケンケンパ
|
ユーザー |
![]() |
提出日時 | 2022-05-25 23:31:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 9 ms / 1,000 ms |
コード長 | 1,198 bytes |
コンパイル時間 | 727 ms |
コンパイル使用メモリ | 94,828 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-09-20 14:50:25 |
合計ジャッジ時間 | 1,542 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
//Yukicoder //Q314 ken-pa //二次元可変配列 //vector <vector <int>> mass; //vector <vector <int>> memo; //#include "stdafx.h" #include <iostream> #include <vector> #include <list>//list #include <set> //tree #include <map> //連想配列 #include <unordered_set> //hash #include <unordered_map> //hash #include <algorithm> #include <iomanip> using namespace std; typedef unsigned long long LL; #define START (0) #define RIGHT (1) #define UP (2) #define LEFT (3) #define DOWN (4) #define DATA_MAX (1000000) #define FMAX(a,b) ((a)>(b)?(a):(b)) #define FMIX(a,b) ((a)<(b)?(a):(b)) vector <vector <LL>> memo2; vector<LL> memo1; vector<LL> T; vector<LL> K; vector<LL> dp; LL N, D; LL ans = 0; int main() { LL total = 0; cin >> N; dp.resize(N + 10); if (N == 1) { cout << 1 << endl; return 0; } else if (N == 2) { cout << 2 << endl; return 0; } else if (N == 3) { cout << 2 << endl; return 0; } // 初期値 dp[0] = 1; dp[1] = 2; dp[2] = 2; LL n = 3; while (1) { dp[n] = (dp[n - 2] + dp[n - 3]) % 1000000007; //毎回 mod を取る n++; if (n >= N) break; } cout << dp[n-1] << endl; //getchar(); return 0; //end }