比赛 寒假集训4 评测结果 WWEEEEEEEE
题目名称 数据结构题 最终得分 0
用户昵称 赵飞羽 运行时间 1.733 s
代码语言 C++ 内存使用 3.47 MiB
提交时间 2026-02-28 11:10:21
显示代码纯文本
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 5010;
int n, m, a[N], op, l, r, x;

int ksm(int x, int k, int p) {
    int res = 1;
	while (k != 0) {
        if (k % 2 == 1) res = res * x % p;
        x = x * x % p;
        k /= 2;
    }
    return res % p;
}

signed main() {
	freopen("sjjgt.in", "r", stdin);
	freopen("sjjgt.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= m; i++) {
		cin >> op >> l >> r >> x;
		if (op == 1) for (int j = l; j <= r; j++) a[j] += x;
		else cout << ksm(a[l], a[r], x) << "\n";
	}
	return 0;
}