RT,我在别的题目上3×108就玄,5×108以上基本就过不了,这道题复杂度是O(modn)大约是109,而且涉嫌取模,为啥能AC,代码:
#include<bits/stdc++.h>
const int mod = 998244353;
int main(){
std::cin.tie(0)->sync_with_stdio(0);
long long n,ans = 0;std::cin >> n;
for (long long i = 0,add = 0;;add++){
if (i + mod <= n){
i += mod;
ans = (ans + mod * add) % mod;
}
else{ans = (ans + (n - i + 1) * add) % mod;break;}
}
std::cout << ans % mod << '\n';
return 0;
}