博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
<cf>System of Equations(水题)
阅读量:7024 次
发布时间:2019-06-28

本文共 1231 字,大约阅读时间需要 4 分钟。

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.

Sample test(s)
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 
int main(){ int n,m; int cnt; while(scanf("%d%d",&n,&m)!=EOF) { cnt=0; for(int i=0;i*i<=n;i++) { double j=n-i*i; if((int)j==j && j*j+i==m) cnt++; } printf("%d\n",cnt); } return 0;}

转载地址:http://idsxl.baihongyu.com/

你可能感兴趣的文章
redis(一) 安装以及基本数据类型操作
查看>>
shell 基础
查看>>
阿里云镜像服务:基于Tag的Docker自动构建
查看>>
map的排序总结
查看>>
ExtJs之Ext.core.DomQuery
查看>>
使用chain方式,在第二action中获取第一个action中actionMessage
查看>>
CentOS安装及配置DNS服务器
查看>>
淘宝Diamond架构分析
查看>>
IE8 jquery ajax获取静态资源报错TypeError 拒绝访问
查看>>
创建完美SDK的10个技巧
查看>>
5、spss做加权最小二乘回归及岭回归
查看>>
Map 按key和value 排序
查看>>
每周一道数据结构(一)图
查看>>
Android 5.x特性概览四
查看>>
归并排序MergeSort
查看>>
十五天精通WCF——第二天 告别烦恼的config配置
查看>>
CYQ.Data 轻量数据访问层(四) 构造数据单元列
查看>>
精美UI界面欣赏[12]
查看>>
UIButton的两种block传值方式
查看>>
深蓝词库转换1.5发布
查看>>