分析可得 \displaystyle\lfloor\frac{n}{i}\rfloor 可以取 \displaystyle1,2,\dots,\sqrt{n},\lfloor\frac{n}{\sqrt{n}}\rfloor,\lfloor\frac{n}{\sqrt{n}-1}\rfloor,\dots n 这 O(\sqrt{n}) 种取值,总复杂度 O(T\sqrt{n})
#include <bits/stdc++.h>
#define int long long
const int mod = 998244353;
using namespace std;
int T, n, ans;
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> T;
while (T--)
{
ans = 0;
cin >> n;
for (int i = 1, j; i <= n; i = j + 1)
{
j = n / (n / i);
ans = (ans + (n / i) * (j - i + 1)) % mod;
}
cout << ans << endl;
}
return 0;
}