当前位置:网站首页>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");
}
}
}
边栏推荐
- C#,数值计算(Numerical Recipes in C#),线性代数方程的求解,Gauss-Jordan消去法,源代码
- Flutter 集成 amap_flutter_location
- Leetcode topic [array] - 121 - the best time to buy and sell stocks
- DM8 tablespace backup and recovery
- Bishi blog (13) -- oral arithmetic test app
- Cancel ctrl+alt+delete when starting up
- std::is_ union,std::is_ class,std::integral_ constant
- Parallel shift does not provide any acceleration - C #
- If the array values match each other, shuffle again - PHP
- Educational Codeforces Round 119 (Rated for Div. 2)
猜你喜欢
埃氏筛+欧拉筛+区间筛
ES6 summary
AcWing 244. Enigmatic cow (tree array + binary search)
How does Xiaobai buy a suitable notebook
How can we make a monthly income of more than 10000? We media people with low income come and have a look
What should I do if there is a problem with the graphics card screen on the computer
FOC控制
go-zero微服务实战系列(九、极致优化秒杀性能)
DM8 tablespace backup and recovery
一文了解數據异常值檢測方法
随机推荐
Moher College webmin unauthenticated remote code execution
Need help resetting PHP counters - PHP
Const string inside function - C #
C # implements a queue in which everything can be sorted
团体程序设计天梯赛-练习集 L2-002 链表去重
What does range mean in PHP
awk从入门到入土(7)条件语句
Parallel shift does not provide any acceleration - C #
Conversion of yolov5 XML dataset to VOC dataset
没有Kubernetes怎么玩Dapr?
awk从入门到入土(9)循环语句
DM database password policy and login restriction settings
团体程序设计天梯赛-练习集 L1-006 连续因子
What should I do if there is a problem with the graphics card screen on the computer
How to play dapr without kubernetes?
Take you to master the formatter of visual studio code
awk从入门到入土(4)用户自定义变量
Codeforces Round #793 (Div. 2)(A-D)
[CV] Wu Enda machine learning course notes | Chapter 9
小程序容器技术与物联网 IoT 可以碰撞出什么样的火花