Run ID:109986
提交时间:2025-02-14 10:08:53
#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 */