0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-10 05:58:48 +00:00

P5596 【XR-4】题

https://www.luogu.com.cn/record/76300560
This commit is contained in:
Baoshuo Ren 2022-05-23 21:25:41 +08:00
parent 49ddbf3558
commit 23271050c2
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

61
Luogu/P5596/P5596.cpp Normal file
View File

@ -0,0 +1,61 @@
#include <cmath>
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
long long a, b, d, m, ans;
int main() {
std::ios::sync_with_stdio(false);
cin >> a >> b;
d = a * a - b * 4;
if (d == 0) {
cout << "inf" << endl;
exit(0);
} else if (d < 0) {
d *= -1;
m = std::sqrt(d);
for (long long q = 1; q <= m; q++) {
if (d % q == 0) {
long long p = d / q;
long long x = p - q - 2 * a,
y = p + q;
if (x % 4 || y % 4) continue;
x /= 4, y /= 4;
if (x >= 0 && y >= x) ans++;
}
}
} else { // d > 0
m = std::sqrt(d);
for (long long q = 1; q <= m; q++) {
if (d % q == 0) {
long long p = d / q;
long long x = p + q - 2 * a,
y = p - q;
if (x % 4 || y % 4) continue;
x /= 4, y /= 4;
if (x >= 0 && y >= x) ans++;
}
}
}
cout << ans << endl;
return 0;
}