codeforces 214A System of Equations

来源:互联网 发布:c语言if语句例题 编辑:程序博客网 时间:2024/06/04 17:41

点击打开链接

A. System of Equations
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?

You are given a system of equations:

You should count, how many there are pairs of integers (a, b) (0 ≤ a, b) which satisfy the system.

Input

A single line contains two integers n, m (1 ≤ n, m ≤ 1000) — the parameters of the system. The numbers on the line are separated by a space.

Output

On a single line print the answer to the problem.

Examples
input
9 3
output
1
input
14 28
output
1
input
4 20
output
0
Note

In the first sample the suitable pair is integers (3, 0). In the second sample the suitable pair is integers (3, 5). In the third sample there is no suitable pair.


水题

#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<cstdlib>using namespace std;int main(){    int n,m,s=0;    cin>>n>>m;    for(int i=0;i<=1000;i++)    {        for(int j=0;j<=1000;j++)        {            if(i*i+j==n&&i+j*j==m)                s++;        }    }    cout<<s<<endl;    return 0;}



原创粉丝点击