結果

問題 No.510 二次漸化式
ユーザー ldsybldsyb
提出日時 2017-04-29 00:00:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 649 bytes
コンパイル時間 503 ms
コンパイル使用メモリ 67,200 KB
実行使用メモリ 10,676 KB
最終ジャッジ日時 2023-10-11 19:56:36
合計ジャッジ時間 29,635 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,676 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 77 ms
4,352 KB
testcase_03 AC 77 ms
4,352 KB
testcase_04 AC 76 ms
4,348 KB
testcase_05 AC 77 ms
4,348 KB
testcase_06 AC 605 ms
4,352 KB
testcase_07 AC 607 ms
4,352 KB
testcase_08 AC 612 ms
4,352 KB
testcase_09 AC 613 ms
4,372 KB
testcase_10 AC 18 ms
4,352 KB
testcase_11 AC 18 ms
4,356 KB
testcase_12 AC 18 ms
4,348 KB
testcase_13 AC 18 ms
4,372 KB
testcase_14 AC 18 ms
4,356 KB
testcase_15 AC 18 ms
4,348 KB
testcase_16 TLE -
testcase_17 AC 2,979 ms
6,636 KB
testcase_18 AC 2,981 ms
6,500 KB
testcase_19 AC 2,992 ms
6,484 KB
testcase_20 AC 2,987 ms
6,492 KB
testcase_21 AC 2,989 ms
6,492 KB
testcase_22 AC 2,965 ms
6,500 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	using ll = long long;
	constexpr ll mod = 1e9 + 7;
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q;
	cin >> n >> q;
	ll a[n + 1], b[n + 1], x[n]{}, y[n]{};
	a[0] = b[0] = 1;
	while(q--){
		char c;
		cin >> c;
		if(c == 'x'){
			ll i, v;
			cin >> i >> v;
			x[i] = v;
		}
		if(c == 'y'){
			ll i, v;
			cin >> i >> v;
			y[i] = v;
		}
		if(c == 'a'){
			int i;
			cin >> i;
			for(int j = 1; j <= i; j++){
				a[j] = (x[j - 1] * b[j - 1] % mod * b[j - 1] % mod + a[j - 1]) % mod;
				b[j] = (y[j - 1] * b[j - 1] % mod + 1) % mod;
			}
			cout << a[i] << endl;
		}
	}
}
0