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