当前位置:网站首页>Chicken and rabbit in the same cage
Chicken and rabbit in the same cage
2022-07-29 17:13:00 【seal ink】
鸡兔同笼
时间限制: 3 Sec 内存限制: 64 MB
题目描述
已知鸡和兔的总数量为n,总腿数为m.输入n和m,依次输出鸡和兔的数目,如果无解,则输出“No answer”(不要引号).
输入
Enter a data on the first linea,It represents the following sets of data,在接下来的(a<10)
a行里,每行都有一个n和m.(m>0,n<100)
输出
Output the number of chickens and rabbits,或者No answer
样例输入
2
14 32
10 16
样例输出
12 2
No answer
#include<stdio.h>
int main()
{
int N;
scanf("%d",&N);
while(N--)
{
int n,m;
int x,y=0;
scanf("%d %d",&n,&m);
for(x=1;x<=n;x++)
{
if(4*x+2*(n-x)==m)
{
printf("%d %d\n",n-x,x);
y=1;
}
}
if(y==0)
printf("No answer\n");
}
return 0;
}
边栏推荐
猜你喜欢

递归法解决N皇后问题

Sentinel热门词汇限流如何实现

阶乘因式分解

Ernie-gram, 显式、完备的 n-gram 掩码语言模型,实现了显式的 n-gram 语义单元知识建模。

CRM如何帮助企业营销获客

大规模线上应用TiDB会遇到的坑,本文都帮你排除好了

【翻译】设备管理器—英特尔网卡属性设置高级选项的功能
![[PCL study notes] Commonly used libraries and APIs for point cloud processing (PCL library Eigen)](/img/b6/0f6113109aef776c777cb25a0ffb95.png)
[PCL study notes] Commonly used libraries and APIs for point cloud processing (PCL library Eigen)

PL5902 SOT-23-5 高效1MHz2A同步DC-DC降压调节器 百盛电子代理商

一文参透分布式存储系统Ceph的架构设计、集群搭建(手把手)
随机推荐
Recall i2i
sorting and searching 二分查找法
MySQL外键约束怎么创建
生产者消费代码
Staggered question explanation
Flutter dynamic | Fair server new version features
CRM如何帮助企业营销获客
接口项目02文档:Jmeter接口测试与性能测试
Property (Property Animation Animation), the basic use of Butterknife butter knife
MLX90640 infrared thermal imager development notes (9)
GMAT考什么?
[PCL study notes] Commonly used libraries and APIs for point cloud processing (PCL library Eigen)
干货!如何使用仪表构造SRv6-TE性能测试环境
传输层 TCP的连接管理-释放连接四次握手
如何在C语言中定义自己的数据类型?
上海移动基于亚信科技AntDB完成核心账务数据库的国产化替换
What is the GMAT test?
[网络]LAN技术堆叠与集群
Loadrunner与Jmeter区别与相同
美国对集成电路及其产品发起337调查:英特尔/联想/宏碁/华硕/微星均涉及其中