0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 14:56:27 +00:00

1257. [CQOI2007] 余数之和 sum

https://hydro.ac/d/bzoj/record/61e4bd2f89300fd2f96794e4
This commit is contained in:
Baoshuo Ren 2022-01-17 08:50:04 +08:00
parent ab440a347a
commit e31a7ee8a2
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

View File

@ -10,8 +10,9 @@ long long n, k, ans;
int main() {
cin >> n >> k;
ans = n * k;
for (int x = 1; x <= n; x++) {
ans -= floor(1.0 * k / x) * x;
for (int x = 1, gx; x <= n; x = gx + 1) {
gx = k / x ? std::min(k / (k / x), n) : n;
ans -= (k / x) * (x + gx) * (gx - x + 1) / 2;
}
cout << ans << endl;
return 0;