题解 | #鸡兔同笼#

鸡兔同笼

https://www.nowcoder.com/practice/fda725b4d9a14010bb145272cababef1

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <map>
using namespace std;

int main() {

    int a; //脚的总数

    //最多的话鸡要多
    //至少的话兔子要多

    while (scanf("%d", &a) != EOF) {

        if (a % 2 != 0) {
            printf("0 0\n");
            continue;
        }

        int rcount = rcount = a / 4; //兔子的数量
        
        if (a % 4 == 0) {
            printf("%d %d\n", rcount, 2 * rcount);
        } else if (a % 4 == 2) {
            printf("%d %d\n", rcount + 1, 2 * rcount + 1);
        }

    }
    return 0;
}

全部评论

相关推荐

练习生懒羊羊:开飞机把这个公司创飞吧
点赞 评论 收藏
分享
nus2201602...:兄弟,你这个简历撕了丢了吧,就是一坨,去找几个项目,理解项目流程,看几遍就是你的了,看看八股就去干了,多看看牛客里别人发出来的简历,对着写,你这写的啥啊,纯一坨
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务