solution

\(y^2-x^2=ax+b\)

\(y^2=x^2+ax+b\)

当\(x^2+ax+b\)为完全平方式时\(Ans=inf\)

\(x \leq y\) 不妨令 \(y=x+t\)

\(x^2+2xt+t^2=x^2+ax+b\)

\(2xt-ax=b-t^2\)

\(x\times(2t-a)=b-t^2\)

\(x=\frac{b-t^2}{2t-a}\)

枚举,找一下使得\(x\)为自然数的\(t\),统计个数即为\(Ans\)

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define int long long
using namespace std; int A,B,Ans; signed main()
{
scanf("%lld%lld",&A,&B);
if(A%2==0&&A*A/4==B){
puts("inf");
return 0;
}
int L1=sqrt(B),L2=A/2;
if(L1>L2) swap(L1,L2);
for(int i=max(L1-1,0ll);i<=L2+1;++i){
if(i*2==A||((B-i*i)<0&&(2*i-A)>0)||((B-i*i)>0&&(2*i-A)<0)) continue;
if((B-i*i)%(2*i-A)==0) ++Ans;
}
printf("%lld\n",Ans);
return 0;
}

最新文章

  1. 从点云到网格(三)Poisson重建
  2. CustomUI Direct3D9_Sample
  3. [荐]使用jQuery清空file文件域
  4. &quot;旋转的风车&quot;----windows(GDI)绘图
  5. [原]cocos2d-lua 常用法汇总
  6. 设计模式-观察者模式(Observer)
  7. LayoutInflater中四种类型inflate方法的介绍
  8. smarty对网页性能的影响--开启opcache
  9. c - 输出 101 至 200之间的素数.
  10. 移动端WEB开发 代码片段
  11. MatLab实现FFT与功率谱
  12. Jquery的一些取值
  13. Flow Problem(最大流)
  14. Qt学习:线程间共享数据(使用信号槽传递数据,必须提前使用qRegisterMetaType来注册参数的类型)
  15. SharePoint 配置传出电子邮件设置
  16. 几个页面loading样式
  17. 捕获arm非托管磁盘虚拟机,并进行还原
  18. Redis基础认识及常用命令使用(一)--转载
  19. python 自然语言处理(三)____条件频率分布
  20. 【Java并发编程】之十四:图文讲述同步的另一个重要功能:内存可见性

热门文章

  1. C#泛型集合之——队列与堆栈
  2. Java自学-数组 增强型for循环
  3. Python进阶----表与表之间的关系(一对一,一对多,多对多),增删改查操作
  4. ES6数组方法总结
  5. 已知IP地址算子网掩码
  6. django的缓存实例应用
  7. The Instruction Set In Cortex-M3
  8. MySQL/MariaDB数据库的主从级联复制
  9. 【转载】.Net 大型分布式基础服务架构横向演变概述
  10. Windows/Linux/Mac下安装mvn