結果

問題 No.510 二次漸化式
ユーザー ldsybldsyb
提出日時 2017-04-29 01:14:31
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 643 bytes
コンパイル時間 1,517 ms
コンパイル使用メモリ 163,204 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-11 20:08:04
合計ジャッジ時間 14,261 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,356 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 192 ms
4,352 KB
testcase_03 AC 194 ms
4,352 KB
testcase_04 AC 121 ms
4,348 KB
testcase_05 AC 121 ms
4,352 KB
testcase_06 AC 1,145 ms
4,348 KB
testcase_07 AC 1,136 ms
4,352 KB
testcase_08 AC 1,834 ms
4,352 KB
testcase_09 AC 1,848 ms
4,348 KB
testcase_10 AC 9 ms
4,352 KB
testcase_11 AC 8 ms
4,348 KB
testcase_12 AC 8 ms
4,352 KB
testcase_13 AC 8 ms
4,352 KB
testcase_14 AC 8 ms
4,348 KB
testcase_15 AC 8 ms
4,348 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
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 <bits/stdc++.h>
using namespace std;

using ll = long long;
ll n, q, i, v, puni, a[100001], b[100001], x[100001], y[100001], mod = 1000000007;
char c;

int main(){
	a[0] = b[0] = 1;
	scanf("%d%d\n", &n, &q);
	for(int muni = 0; muni < q; muni++){
		scanf("%c", &c);
		if(c == 'a'){
			if(puni != 10000000){
				for(int i = puni; i < n; i++){
					a[i + 1] = (x[i] * b[i] % mod * b[i] + a[i]) % mod;
					b[i + 1] = (y[i] * b[i] + 1) % mod;
				}
				puni = 10000000;
			}
			scanf("%d\n", &i);
			printf("%lld\n", a[i]);
		}else{
			scanf("%d %d\n", &i, &v);
			if(c == 'x') x[i] = v;
			else y[i] = v;
			puni = min(puni, i);
		}
	}
}
0