mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-28 12:31:59 +00:00
1257. [CQOI2007] 余数之和 sum
https://hydro.ac/d/bzoj/record/61e4bd2f89300fd2f96794e4
This commit is contained in:
parent
ab440a347a
commit
e31a7ee8a2
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user