题解 | 百钱买百鸡问题
百钱买百鸡问题
https://www.nowcoder.com/practice/74c493f094304ea2bda37d0dc40dc85b
#include <stdio.h> int main() { int a, b; while (scanf("%d", &a) != EOF) { for(a = 0;a < 20;a++) { for(b = 0;b < 100;b++) { if((a * 2 + b / 3 + 300 - b * 3 == 100) && ((a + b) <= 100) && (b % 3 == 0)) printf("%d %d %d\n",a,(100-a-b),b); } } } return 0; }