Untitled
unknown
plain_text
3 years ago
614 B
4
Indexable
#include <bits/stdc++.h>
using namespace std;
long long int l, r, x, ans, u, v, dif, q, a, b;
void solve(){
cin>>q;
while(q--){
ans=0;
cin>>l>>r>>a>>b;
if(b<a){
swap(b, a);
}
dif=b-a;
for(int i=1; i*i<=dif; i++){
if(dif%i==0){
v=(i+dif/i)/2;
u=(dif/i-i)/2;
x=u*u-a;
if(x>=l && x<=r){
ans++;
}
}
}
cout<<ans<<endl;
}
}
int main(){
solve();
return 0;
}Editor is loading...