题解 | #百钱买百鸡问题#
百钱买百鸡问题
https://www.nowcoder.com/practice/74c493f094304ea2bda37d0dc40dc85b
#include <iostream>
using namespace std;
int main() {
int a,x,y,threez;
while (cin >> a) { // 注意 while 处理多个 case
for(threez=0;threez<=99;threez=threez+3)
{
for(x=0;100-x-threez>=0;x++)
{
y=100-x-threez;
int z=threez/3;
if(x*5+y*3+z==100)
{
cout<<x<<" "<<y<<" "<<threez<<" "<<endl;
}
}
}
}
}
// 64 位输出请用 printf("%lld")
校招随便写写 文章被收录于专栏
简单记录自己刷题
查看14道真题和解析