题解 P5596 【【XR-4】题】
数学题。
好题啊(
首先判断无限解情况,将
然后来考虑怎么解此题,我们将左式因式分解,得:
令
然后我们就可以枚举
#include<bits/stdc++.h>
#define MAXN
#define reg register
#define inl inline
#define int long long
using namespace std;
int a,b,ans;
signed main()
{
scanf("%lld %lld",&a,&b);
if(a*a==4*b) return puts("inf"),0;
reg int x=1,t=sqrt(b);
if(t*t==b) ans++;
while(1)
{
reg int A=x*2-a,B=b-x*x;
if(((A>0 && B>0) || (A<0 && B<0)) && !(B%A)) ans++;
if(A>0 && B<0) break;
x++;
}
printf("%lld\n",ans);
return 0;
}