当前位置:网站首页>1211 or chicken and rabbit in the same cage
1211 or chicken and rabbit in the same cage
2022-07-04 08:41:00 【Zhanglilong 666】
Title Description
There are chickens and rabbits in a cage ( Chicken has 2 One foot , The rabbit has 4 One foot ). We already know the total number of feet in the cage a, Ask how many animals there are in the cage at least , How many animals at most .
Input requirements
The first line is the number of groups of test data n, Follow behind n Line input . Each group of test data takes up one line , Each line contains a positive integer a, Represents the total number of feet in the cage .
Output requirements
The output contains n That's ok , Each line corresponds to one input , contain 2 A positive integer , The first is the minimum number of animals , The second is the largest number of animals . If there is no answer that meets the requirements , Then output two 0.
sample input
2 3 20
sample output
0 0 5 10
#include<cstdio>
#include<math.h>
int main(){
int n,x,y,i,j,k,max,N,zll=0,set=1,six,five,four;
scanf("%d",&x);
for(i=0;i<x;++i){
scanf("%d",&y);
if(y%2==0&&y!=0){
if(y%4==0){
printf("%d ",y/4);
}
else{
if(y%4==2){
printf("%d ",(y/4)+1);
}
}
printf("%d\n",y/2);
}
else{
printf("0 0\n");
}
}
}
边栏推荐
猜你喜欢
Comparison between sentinel and hystrix
A method for detecting outliers of data
[CV] Wu Enda machine learning course notes | Chapter 9
snipaste 方便的截图软件,可以复制在屏幕上
OpenFeign 服务接口调用
Developers really review CSDN question and answer function, and there are many improvements~
DM8 command line installation and database creation
Codeforces Round #803 (Div. 2)(A-D)
awk从入门到入土(12)awk也可以写脚本,替代shell
How college students choose suitable computers
随机推荐
转:优秀的管理者,关注的不是错误,而是优势
【无标题】转发最小二乘法
How to send pictures to the server in the form of file stream through the upload control of antd
Flutter 集成 amap_flutter_location
微服务入门:Gateway网关
C#实现一个万物皆可排序的队列
The second session of the question swiping and punching activity -- solving the switching problem with recursion as the background (I)
awk从入门到入土(18)gawk线上手册
awk从入门到入土(12)awk也可以写脚本,替代shell
Conversion of yolov5 XML dataset to VOC dataset
Newh3c - routing protocol (RIP, OSPF)
Ehrlich sieve + Euler sieve + interval sieve
Example analysis of C # read / write lock
DM8 tablespace backup and recovery
The right way to capture assertion failures in NUnit - C #
FRP intranet penetration, reverse proxy
How college students choose suitable computers
HMS core helps baby bus show high-quality children's digital content to global developers
The upper layer route cannot Ping the lower layer route
Technology sharing | MySQL parallel DDL