题解 | #百钱买百鸡问题#

百钱买百鸡问题

http://www.nowcoder.com/practice/74c493f094304ea2bda37d0dc40dc85b

#include<bits/stdc++.h>

using namespace std;

int main(){
    int num = 0;
    cin>>num;
    int n1 = 0; // 鸡翁个数
    int n2 = 0; // 鸡母个数
    int n3 = 3; // 鸡雏个数
    for(n1 = 0; n1 < 20; n1++){
        for(n2 = 0; n2 < 33; n2++){
            for(n3 = 0; n3 < 100; n3 = n3 + 3){ //
                if(n1 + n2 + n3 == 100 && 5*n1 + 3*n2 + n3/3 == 100){
                    cout<< n1 <<" " <<n2 <<  " " << n3<<endl;
                }
            }
        }
    }         
    return 0;
}
华为题库题解 文章被收录于专栏

牛客华为题库的题解

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务