結果
問題 | No.314 ケンケンパ |
ユーザー |
|
提出日時 | 2020-04-13 22:15:52 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 11 ms / 1,000 ms |
コード長 | 510 bytes |
コンパイル時間 | 1,331 ms |
コンパイル使用メモリ | 69,756 KB |
最終ジャッジ日時 | 2025-01-09 18:14:50 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <iostream>#include <vector>using lint = long long;constexpr lint MOD = 1e9 + 7;void solve() {int n;std::cin >> n;if (n < 3) {std::cout << n << std::endl;return;}lint a = 0, b = 0, c = 1;while (n--) {lint d = (a + b) % MOD;a = b;b = c;c = d;}std::cout << (a + b + c) % MOD << std::endl;}int main() {std::cin.tie(nullptr);std::ios::sync_with_stdio(false);solve();return 0;}