結果

問題 No.891 隣接3項間の漸化式
ユーザー seryuseryu
提出日時 2019-10-01 08:55:45
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 661 bytes
コンパイル時間 654 ms
コンパイル使用メモリ 72,380 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 08:30:32
合計ジャッジ時間 7,271 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 85 ms
6,944 KB
testcase_04 AC 164 ms
6,940 KB
testcase_05 AC 170 ms
6,940 KB
testcase_06 AC 224 ms
6,940 KB
testcase_07 AC 157 ms
6,944 KB
testcase_08 AC 143 ms
6,944 KB
testcase_09 AC 188 ms
6,940 KB
testcase_10 AC 33 ms
6,940 KB
testcase_11 AC 91 ms
6,940 KB
testcase_12 AC 264 ms
6,940 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 163 ms
6,944 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 19 ms
6,940 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 26 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0