Codeforces 214A - A. System of Equations

214A - A. System of Equations

全探索。

calc n m = sum [1 | a<-[0..1000], b<-[0..1000], a^2+b==n, a+b^2==m]

main = do s <- getLine
          let xs = map (\x -> read x :: Int) $ words s
          let (n, m) = (xs!!0, xs!!1)
          putStrLn $ show $ calc n m