第一部分 m⋅2(q0−1)⋅q 是 m 的倍数,对 m 取模的结果为 0,所以最终结果为 q0⋅(r+1)modm。
代码
C++
#include<bits/stdc++.h>#define int long longusing namespace std;
const int Mod=998244353;
int n;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n;
int q0 = n / Mod;
int r = n % Mod;
int ans = (q0 * (r + 1)) % Mod;
cout << ans << "\n";
return 0;
}