結果
| 問題 |
No.891 隣接3項間の漸化式
|
| コンテスト | |
| ユーザー |
trineutron
|
| 提出日時 | 2019-05-07 00:45:08 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 374 bytes |
| コンパイル時間 | 1,289 ms |
| コンパイル使用メモリ | 159,300 KB |
| 実行使用メモリ | 166,120 KB |
| 最終ジャッジ日時 | 2024-11-06 12:41:37 |
| 合計ジャッジ時間 | 6,209 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 TLE * 1 -- * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main()
{
const long div = 1000000007;
long a, b, n, prev = 0, current = 1;
cin >> a >> b >> n;
if (n < 2) {
cout << n << endl;
return 0;
}
for (int i = 2; i <= n; i++) {
long next = (a * current % div + b * prev % div) % div;
prev = current;
current = next;
}
cout << current << endl;
}
trineutron