题解 | #鸡兔同笼#
鸡兔同笼
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; }