题目
代码
Code
// https://atcoder.jp/contests/abc090/tasks/arc091_b
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
void solv()
{
int n, k;
cin >> n >> k;
LL cnt = 0;
for (int b = k+1; b <= n; b ++)
{
// a = b * x + k <= n
LL t = 1ll * (b - k) * (n / b) + max(0, n % b - k + 1) - (k == 0);
cnt += t;
// cout << b << " --> " << t << endl;
}
cout << cnt << endl;
}
int main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int T = 1;
// cin >> T;
while (T --)
{
solv();
}
return 0;
}