0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 18:11:59 +00:00

P2261 [CQOI2007]余数求和

https://www.luogu.com.cn/record/76170293
This commit is contained in:
Baoshuo Ren 2022-05-21 20:11:36 +08:00
parent 0932ac15cd
commit 728d3da95e
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

29
Luogu/P2261/P2261.cpp Normal file
View File

@ -0,0 +1,29 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
long long n, k, ans;
int main() {
std::ios::sync_with_stdio(false);
cin >> n >> k;
ans = n * k;
for (long long l = 1, r; l <= n; l = r + 1) {
if (k / l) {
r = std::min(k / (k / l), n);
} else {
r = n;
}
ans -= (r + l) * (k / l) * (r - l + 1) / 2;
}
cout << ans << endl;
return 0;
}