結果

問題 No.510 二次漸化式
ユーザー impedance_BS
提出日時 2017-04-28 23:42:43
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 771 bytes
コンパイル時間 534 ms
コンパイル使用メモリ 61,004 KB
実行使用メモリ 13,884 KB
最終ジャッジ日時 2024-09-13 18:42:06
合計ジャッジ時間 33,068 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 3 WA * 29 TLE * 2
権限があれば一括ダウンロードができます

ソースコード

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