若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。


  • 运维

  • 前端

  • 编程

  • 随笔

  • hust-oj

1014: C hicken and rabbit s

发表于 2017-10-06   |   分类于 HUSTOJ   |   阅读次数 1,221

题目描述

Chicken and rabbits are in a same cage. As we all know, chicken has two legs but rabbit has four. Now
we know the number of legs in the cage is A, please tell me how many animals may in the cage at least
and at most.

输入

The first line of the input contains the number of test cases in the file. Each test case that follows
consists of one lines. each case contains only one integer numbers A specifying the total legs in the
cage .

输出

For each test case, print a line contains the answer

样例输入

2
3
20

样例输出

0 0
5 10

参考代码

#include<stdio.h>
int main() 
{
    int i,t,n,ji,tu;
    scanf("%d",&t);
    for (i=0;i<t;i++) 
    {
        scanf("%d",&n);
        if(n%2==1) printf("0 0n");
        else if(n%4==0)
        {
            tu=n/4;
            ji=n/2;
            printf("%d %dn",tu,ji);
        }
        else
        {
            tu=(n-2)/4+1;
            ji=n/2;
            printf("%d %dn",tu,ji);
        }
    }
    return 0;
}

解析

暂无

hustoj

发表评论 取消回复

邮箱地址不会被公开。 必填项已用*标注

*
*


hoxis wechat
著作权归作者所有
站点更新说明
  • 文章目录
  • 站点概览
若是凉夜已成梦

若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。

1904 日志
6 分类
12 标签
RSS
weibo github twitter facebook

友情链接

Skip 原站点 Dreams孤独患者
© 2017 若是凉夜已成梦
Powered by WordPress | 已运行
Theme By NexT.Mist