Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
109986 胡海峰老师 百钱买百鸡II C++ Accepted 3 MS 272 KB 541 2025-02-14 10:08:53

Tests(10/10):


Code:

#include <iostream> using namespace std; int main(){ int n; cin>>n; int x,y,z,i=1; for(x =0 ; x<=n;x++) for(y=0;y<=n;y++) { z = n - x -y; //1 24 75 (78) if( 5*x+3*y+z/3==n && z%3==0 ) { cout<<i<<": "<<x<<","<<y<<","<<z<<endl; i++; } } if(i==1) cout<<"None"; return 0; } /* 设公鸡、母鸡、小鸡分别为x、y、z 只,由题意得: x+y+z=100①式 5x+3y+(1/3)z=100②式 Input 100 Output 1: 0,25,75 2: 4,18,78 3: 8,11,81 4: 12,4,84 */