题解 | #百钱买百鸡问题#
百钱买百鸡问题
https://www.nowcoder.com/practice/74c493f094304ea2bda37d0dc40dc85b
// HJ72-2 百钱买百鸡问题.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 #include<iostream> #include<bits/stdc++.h> using namespace std; int main() { int n = 0; while (cin >> n) { int x = 0, y = 0, z = 0; for (int x = 0; x < 13; x++) { for (int y = 0; y < 26; y++) { for (int z = 0; z < 85; z++) { if (x * 5 + y * 3 + int(z * 1 / 3) == 100 && x + y + z == 100 && z % 3 == 0) { cout << x << " " << y << " " << z << endl; } } } } } return 0; }