結果
| 問題 |
No.891 隣接3項間の漸化式
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-01 08:55:45 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 661 bytes |
| コンパイル時間 | 1,102 ms |
| コンパイル使用メモリ | 72,460 KB |
| 実行使用メモリ | 13,636 KB |
| 最終ジャッジ日時 | 2024-10-03 05:38:52 |
| 合計ジャッジ時間 | 6,457 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 TLE * 1 -- * 16 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;
int main()
{
ll a, b, n;
cin >> a >> b >> n;
ll x;
if (n == 0)x = 0;
else if (n == 1)x == 1;
else
{
ll x_last = 1;
ll x_last2 = 0;
rep(i, n - 1)
{
x = (a * x_last + b * x_last2) % mod;
x_last2 = x_last;
x_last = x;
}
}
co(x);
return 0;
}