結果
問題 | No.314 ケンケンパ |
ユーザー | lapi |
提出日時 | 2019-04-02 22:41:47 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 11 ms / 1,000 ms |
コード長 | 960 bytes |
コンパイル時間 | 1,130 ms |
コンパイル使用メモリ | 100,684 KB |
実行使用メモリ | 26,768 KB |
最終ジャッジ日時 | 2023-08-21 03:13:00 |
合計ジャッジ時間 | 2,083 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 10 ms
26,660 KB |
testcase_01 | AC | 2 ms
7,436 KB |
testcase_02 | AC | 2 ms
7,648 KB |
testcase_03 | AC | 3 ms
7,480 KB |
testcase_04 | AC | 2 ms
7,468 KB |
testcase_05 | AC | 2 ms
7,420 KB |
testcase_06 | AC | 3 ms
7,568 KB |
testcase_07 | AC | 3 ms
7,432 KB |
testcase_08 | AC | 2 ms
7,440 KB |
testcase_09 | AC | 2 ms
7,492 KB |
testcase_10 | AC | 2 ms
7,560 KB |
testcase_11 | AC | 3 ms
7,536 KB |
testcase_12 | AC | 2 ms
7,564 KB |
testcase_13 | AC | 2 ms
7,476 KB |
testcase_14 | AC | 2 ms
7,476 KB |
testcase_15 | AC | 3 ms
7,536 KB |
testcase_16 | AC | 2 ms
7,636 KB |
testcase_17 | AC | 4 ms
12,340 KB |
testcase_18 | AC | 8 ms
19,700 KB |
testcase_19 | AC | 11 ms
26,768 KB |
ソースコード
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <stack> #include <queue> #include <list> #include <set> #include <map> #include <numeric> #include <regex> #include <tuple> #include<iomanip> using namespace std; typedef long long ll; typedef pair<int, int> P; #define MOD 1000000007 // 10^9 + 7 #define INF 1000000000 // 10^9 #define LLINF 1LL<<60 ll pa[1000001]; // n回目がpaとなるような総数 ll firstKen[1000001]; // n回目が初めてのkenとなるような総数 ll secondKen[1000001]; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; pa[1] = 0; firstKen[1] = 1; secondKen[1] = 0; for (int i = 2; i <= N; i++) { pa[i] = (firstKen[i - 1] + secondKen[i - 1]); pa[i] %= MOD; firstKen[i] = pa[i - 1]; firstKen[i] %= MOD; secondKen[i] = firstKen[i - 1]; secondKen[i] %= MOD; } cout << (pa[N] + firstKen[N] + secondKen[N]) % MOD << endl; return 0; }