求
其中1 <= n <= 1e9, 1 <= k <= 1e9
把取模拆开
注意到
代码:
#include <iostream>
using namespace std;
typedef long long LL;
(int l, int r) {
LL sumreturn (LL)(l + r) * (r - l + 1) / 2;
}
int main() {
int n, k;
>> n >> k;
cin = 0;
LL ans for (int i = 1, r; i <= k && i <= n; i = r + 1) {
int d = k / i;
= k / d;
r += d * sum(i, min(r, n));
ans }
= (LL)n * k - ans;
ans << ans << endl;
cout
return 0;
}