結果

問題 No.510 二次漸化式
ユーザー impedance_BSimpedance_BS
提出日時 2017-04-28 23:42:43
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 771 bytes
コンパイル時間 902 ms
コンパイル使用メモリ 60,904 KB
実行使用メモリ 10,792 KB
最終ジャッジ日時 2023-10-11 19:51:28
合計ジャッジ時間 33,524 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 988 ms
6,160 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 16 ms
6,268 KB
testcase_32 AC 15 ms
6,188 KB
testcase_33 WA -
testcase_34 TLE -
testcase_35 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;
using ulli = unsigned long long int;

void update(	vector<ulli> & a,
		vector<ulli> & b,
		vector<ulli> & x,
		vector<ulli> & y, int pos){

	for(int i = 1; i <= pos; ++i){
		a[i] = x[i - 1] * b[i - 1] * b[i - 1] + a[i - 1];
		b[i] = y[i - 1] * b[i - 1] + 1;
	}
}
	

int main(void){
	ulli n, q;
	
	cin >> n >> q;
	++n;
	vector<ulli> a(n), b(n), x(n), y(n);
	
	a[0] = b[0] = 1;
	for(int i = 0; i < n; ++i){
		x[i] = y[i] = 0;
	}
	for(int i = 0; i < q; ++i){
		char query;
		ulli pos;
		cin >> query;
		cin >> pos;
		if(query == 'a'){
			update(a, b, x, y, pos);
			cout << a[pos] % (1000000000 + 7) << endl;
		}
		if(query == 'x')	cin >> x[pos];
		if(query == 'y')	cin >> y[pos];
	}
	return 0;
}
0