比赛 2024暑假C班集训E 评测结果 TTTWTWTATATTWWWWTWTW
题目名称 相逢是问候 最终得分 10
用户昵称 LikableP 运行时间 36.849 s
代码语言 C++ 内存使用 3.45 MiB
提交时间 2024-07-14 11:50:41
显示代码纯文本
#include <iostream>
#include <fstream>
using namespace std;

unsigned long long n, m, p, c;
unsigned long long a[50010];

unsigned long long kasumi(unsigned long long x, unsigned long long y){
	unsigned long long res = 1;
	while(y){
		if(y & 1){
			res *= x;
		}
		x *= x;
		y >>= 1;
	}
	return res;
}

int main(){
	freopen("verbinden.in", "r", stdin);
	freopen("verbinden.out", "w", stdout);
	cin >> n >> m >> p >> c;
	for(unsigned long long i = 1; i <= n; i++) cin >> a[i];
	while(m--){
		unsigned long long op, l, r;
		cin >> op >> l >> r;
		if(op){
			unsigned long long sum = 0;
			for(unsigned long long i = l; i <= r; i++) (sum += a[i]) %= p;
			cout << sum % p << endl;
		}else{
			for(unsigned long long i = l; i <= r; i++) a[i] = kasumi(c, a[i]);
		}
	}
	return 0;
}