暴力 WA on test 3 求调!(悬关)
查看原帖
暴力 WA on test 3 求调!(悬关)
804607
rainygame楼主2023/5/13 23:08
#include <bits/stdc++.h>
using namespace std;

int n, m, vmax, op, l, r, x, y;
int a[100001], b[100001];
long long seed;

int rnd(){
	int ret = seed;
    seed = (seed * 7 + 13) % 1000000007;
    return ret;
}

int qpow(int a, int k, int p){
	long long res(a);
	while (k){
		if (k & 1) res = (res * a) % p;
		a = (a * a) % p;
		k >>= 1;
	}
	return res;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n >> m >> seed >> vmax;
	for (int i(1); i<=n; ++i) a[i] = rnd() % vmax + 1;
	
	while (m--){
		op = (rnd() % 4) + 1;
		l = (rnd() % n) + 1;
		r = (rnd() % n) + 1;
		if (l > r) swap(l, r);
		
		if (op == 3) x = (rnd() % (r-l+1)) + 1;
		else x = (rnd() % vmax) + 1;
		if (op == 4) y = (rnd() % vmax) + 1;
		
		if (op == 1){
			for (int i(l); i<=r; ++i) a[i] += x;
		}else if (op == 2){
			for (int i(l); i<=r; ++i) a[i] = x;
		}else if (op == 3){
			memcpy(b, a, sizeof(a));
			sort(b+l, b+r+1);
			cout << b[l+x-1] << '\n';
		}else{
			long long ans(0);
			for (int i(l); i<=r; ++i) ans = (ans + qpow(a[i], x-1, y)) % y;
			cout << ans << '\n'; 
		}
	}
	
	return 0;
}

2023/5/13 23:08
加载中...