C. Floor and Mod(整数分块)
题意:
给定x,y,有两数a,b,满足1<=a<=x,1<=b<=y,求满足(a/b)=a%b的<a,b>对数。
思路:
首先暴力肯定会T,因为O(y * 100),max(y)=1e9
T1的代码:
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
int main()
{
//freopen("in.txt", "r", stdin);
int T;
scanf("%d", &T);
while(T--)
{
ll l,r;
scanf("%lld%lld", &l, &r);
ll ans = 0;
for (ll i = 2; i <= r;i++){
if(l<=i)
break;
if((i-1)*i+(i-1)<=l)
ans += i - 1;
else if(l%i>=l/i