[CF1485C] Floor and Mod - 数论
Description
求 (1le ale x,1le ble y) 且 (lfloorfrac{a}{b} floor =amod b) 的((a,b)) 个数
Solution
设 (lfloorfrac{a}{b} floor =amod b = r),这个 r 显然是不会超过 (sqrt a) 的,一次枚举即可
对于一个确定的 r,方案数是可以 O(1) 求出的
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
ios::sync_with_stdio(false);
int t;
cin >> t;
while (t--)
{
int x, y;
cin >> x >> y;
int ans = 0;
for (int i = 1; i <= 5e4; i++)
ans += max(0ll, min(y, x / i - 1) - i);
cout << ans << endl;
}
}