Skip to content
Onsite

System of Equations Pairs

EasyP3Coding

Given two integers n and m, count the pairs of non-negative integers (x, y) that satisfy both equations:

x^2 + y = n
y^2 + x = m

Example 1

Input
n = 9, m = 3
Output
1

Example 2

Input
n = 14, m = 28
Output
1

Example 3

Input
n = 4, m = 20
Output
0

Constraints

  • 0 <= n, m <= 10^6

Hints

Run checks the 3 visible tests, Submit all 10.