The problem is from codeforces: http://www.codeforces.com/problemset/problem/214/A
Simple as that, the brute-force can pass the tests. The given ranges for n and m are acceptable for the simple brute-force algorithm.
#!/usr/bin/env python
# https://helloacm.com
n, m = map(int, raw_input().split(' '))
x = 0
for a in xrange(0, int(n ** 0.5) + 1):
b = n - a * a
if b >= 0 and a + b * b == m:
x += 1
print x
–EOF (The Ultimate Computing & Technology Blog) —
Last Post: How Many Zeros at the end of 1024!?
Next Post: A Javascript PC Emulator