C hicken and rabbit s

时间限制: 1 Sec  内存限制:
32 MB

提交: 40  解决: 29

[提交][状态][讨论版]

题目描述

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 n;
    scanf("%d",&n);
    while(n--)
    {
        long long m;
        scanf("%lld",&m);
        if(m%2==1)
        {
            printf("0 0\n");
            continue;
        }
        if(m%4==0)
        printf("%lld ",m/4);
        else
        printf("%lld ",m/4+1);
        printf("%lld\n",m/2);
    }
    return 0;
    }
/**************************************************************
    Problem: 1205
    Language: C
    Result: 正确
    Time:0 ms
    Memory:768 kb
****************************************************************/

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-11-02 21:59:59

C hicken and rabbit s的相关文章

hdu 5030 Rabbit&#39;s String(后缀数组&amp;二分)

Rabbit's String Time Limit: 40000/20000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 288    Accepted Submission(s): 108 Problem Description Long long ago, there lived a lot of rabbits in the forest. One day, the

HDU4057 Rescue the Rabbit(AC自动机+状压DP)

题目大概是给几个DNA片段以及它们各自的权值,如果一个DNA包含某个片段那么它的价值就加上这个片段的权值,同时包含多个相同DNA片段也只加一次,问长度l的DNA可能的最大价值. 与HDU2825大同小异. dp[i][j][S]表示长度i(自动机转移i步).后缀状态为自动机第j个结点.包含的DNA片段为集合S 的DNA最大价值 dp[0][0][0]=0 我为人人转移,从dp[i][j][S]向ATCG四个方向更新dp[i+1][j'][S'] 注意的是要用滚动数组,不然要开上百兆数组. 用滚动

HDU1849 Rabbit and Grass()

用异或看取得的值是否为0判断 思想换没搞懂 #include<stdio.h> int main() { int ans,n,a; while(scanf("%d",&n),n){ ans=0; while(n--){ scanf("%d",&a); ans=ans^a; } if(ans==0) printf("Grass Win!\n"); else printf("Rabbit Win!\n"

HDU 4057 Rescue the Rabbit (AC自动机+DP)

http://acm.hdu.edu.cn/showproblem.php?pid=4057 Rescue the Rabbit Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1482    Accepted Submission(s): 430 Problem Description Dr. X is a biologist,

HDU - 1849 - Rabbit and Grass

先上题目: Rabbit and Grass Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2097    Accepted Submission(s): 1579 Problem Description 大学时光是浪漫的,女生是浪漫的,圣诞更是浪漫的,但是Rabbit和Grass这两个大学女生在今年的圣诞节却表现得一点都不浪漫:不去逛

13杭州区域赛现场赛Rabbit Kingdom(树状数组+离线)

题意:给你一个长度数列,再给你m个询问(一个区间),问你在这个区间里面有多少个数与其他的数都互质. 解题思路:你看这种类型的题目都可以肯定这是 离线+树状数组(线段树).主要就是他的更新信息.这里我的处理是先把1-200000(每个数的范围)数里面所有的质因子求出来.然后从后往前遍历数组.会出现以下几种情况 1.a[k]的质因子在后面出现过而[更新标记] 和[被更新标记] 都为假 2.a[k]的质因子在后面出现过的那个位置 I   [更新标记]为 真 . 3.a[k]的质因子在后面出现过且那个位

POJ2606 Rabbit hunt

问题链接:POJ2606 Rabbit hunt. 题意简述:输入n,输入n个整数对,即n个坐标点,问最多共线点数是多少. 问题分析:用暴力法解决这个问题,好在计算规模不算大. 程序中,判断共线时,使用的是乘法,没有用除法,可以保证精确的计算结果. 这个问题与POJ1118 HDU1432 Lining Up基本上相同,只是输入数据格式略有不同. AC的C语言程序如下: /* POJ2606 Rabbit hunt */ #include <stdio.h> #define MAXN 200

转化为用欧几里得算法判断互质的问题D - Wolf and Rabbit

Description There is a hill with n holes around. The holes are signed from 0 to n-1. A rabbit must hide in one of the holes. A wolf searches the rabbit in anticlockwise order. The first hole he get into is the one signed with 0. Then he will get into

hdu 5030 Rabbit&#39;s String(后缀数组)

题目链接:hdu 5030 Rabbit's String 题目大意:给定k和一个字符串,要求将字符串拆分成k个子串.然后将每个子串中字典序最大的子串选出来,组成一个包含k个字符串的集合,要求这个集合中字典序最大的字符串字典序最小. 解题思路:网赛的时候试图搞了一下这道题,不过水平还是有限啊,后缀数组也是初学,只会切一些水题.赛后看了一下别人的题解,把这题补上了. 首先对整个字符串做后缀数组,除了处理出sa,rank,height数组,还要处理处f数组,f[i]表示说以0~sa[i]开头共有多少