Type: Default 1000ms 256MiB

练39.4 百钱买百鸡

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

说明

百钱买百鸡问题:33文钱可以买11只公鸡,22文钱可以买1只母鸡,11文钱可以买33只小鸡,要用100100文钱买100100只鸡,求公鸡,母鸡,小鸡各多少只?
三种鸡的数量都大于0!

输入格式

无。

输出格式

第一行分别输出公鸡,母鸡,小鸡,按每个词语占55个字符的宽度。接着输出各种公鸡、母鸡、小鸡的数量,依次由小到大,每种情况各占一行&#44,并每个整数占55个字符的宽度。

样例

5    32    63
   10    24    66
   15    16    69
   20     8    72
#include<cstdio>
using namespace std;
// 枚举法 
int main(){
	int n=100;    //鸡的数量
	int money=100;//有的钱
	for(int gong=1;gong<=100;gong++){
		for(int mu=1;mu<=100;mu++){
			for(int xiao=1;xiao<=100;xiao++){
				if(gong+mu+xiao==100 && gong*3+mu*2+xiao/3*1==100  && xiao%3==0){
					printf("%5d %5d %5d\n",gong ,mu, xiao);
				}
			}
		}
	}
	return 0;
}

AShui0708堂训

Not Claimed
Status
Done
Problem
11
Open Since
2025-7-8 0:00
Deadline
2025-7-16 23:59
Extension
24 hour(s)