P9552 题解
题目传送门
思路
对于
而
证明
为什么让
代码
# include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 998244353;
int t, op;
ll n, m, q;
int main () {
cin >> t;
while (t --) {
cin >> op >> n >> m;
if (op < 2)
cout << n + m - 1 << '\n';
else {
cin >> q;
cout << min (n, m) % mod * ((q - n - m + 1) % mod) % mod << '\n';
}
}
return 0;
}