每日一九度之 题目1045:百鸡问题

时间限制:1 秒

内存限制:32 兆

特殊判题:

提交:10023

解决:4391

题目描述:

    用小于等于n元去买100只鸡,大鸡5元/只,小鸡3元/只,还有1/3元每只的一种小鸡,分别记为x只,y只,z只。编程求解x,y,z所有可能解。

输入:

    测试数据有多组,输入n。

输出:

    对于每组输入,请输出x,y,z所有可行解,按照x,y,z依次增大的顺序输出。

样例输入:
40
样例输出:
x=0,y=0,z=100
x=0,y=1,z=99
x=0,y=2,z=98
x=1,y=0,z=99

今天满课,有点忙,实在没时间,抽空刷了道水题。

//Asimple
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <limits.h>
#define INF 0x7fffffff
using namespace std;
const int maxn = 1005;
typedef long long ll;
int n, num;

int main(){
    while( ~scanf("%d",&n) ){
        for(int x=0; x<100; x++){
            for(int y=0; y<100; y++){
                if( 14*x + 8*y + 100 <= 3*n ){
                    printf("x=%d,y=%d,z=%d
",x,y,100-x-y);
                }
            }
        }
    }
    return 0;
}
低调做人,高调做事。
原文地址:https://www.cnblogs.com/Asimple/p/5893750.html