#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
ll t, a, b, i;
cin >> t;
while(t--)
{
cin >> a >> b;
if(a == b)
{
cout << -1 << "\n";
continue;
}
ll r = abs(a-b);
int c = 0;
for(i=1;i<=sqrt(r);i++)
{
if(r%i == 0)
{
c++;
if(i != r/i)
c++;
}
}
cout << c << "\n";
}
return 0;
}
#define ll long long int
using namespace std;
int main()
{
ll t, a, b, i;
cin >> t;
while(t--)
{
cin >> a >> b;
if(a == b)
{
cout << -1 << "\n";
continue;
}
ll r = abs(a-b);
int c = 0;
for(i=1;i<=sqrt(r);i++)
{
if(r%i == 0)
{
c++;
if(i != r/i)
c++;
}
}
cout << c << "\n";
}
return 0;
}
Comments
Post a Comment