标签:多少 main can const its include lan sim define
题意:
问多少对 \(a,b\) 满足 \(\lfloor \frac{a}{b} \rfloor =a\ mod\ b\) 。
其中 \(1\leqslant a\leqslant x,1\leqslant b\leqslant y\) 。
想法:
代码:
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int maxn=100005;
int main()
{
int T;
ll a,b;
cin>>T;
while(T--){
scanf("%lld%lld",&a,&b);
ll num=sqrt(a+1);
ll ans=0;
if(num>b){
num=b;
ans+=(num)*(num-1)/2;
}else{
ans+=(num)*(num-1)/2;
for(ll l=num+1,r;l<=min(a,b);l=r+1){
if(a/(l+1)==0)break;
else{
r=min(b,min(a,a/(a/(l+1))-1));
}
ans+=(r-l+1)*(a/(l+1));
}
}
cout<<ans<<endl;
}
return 0;
}
标签:多少 main can const its include lan sim define
原文地址:https://www.cnblogs.com/ha-chuochuo/p/14403581.html