首页 > 试题广场 >

百鸡问题

[编程题]百鸡问题
  • 热度指数:45889 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
    用小于等于n元去买100只鸡,大鸡5元/只,小鸡3元/只,还有1/3元每只的一种小鸡,分别记为x只,y只,z只。编程求解x,y,z所有可能解。
(本题没有测试数据,
int main(){}
就能通过
真·本地过了就是过了)


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


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

输入

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
头像 鱼儿恋上水
发表于 2020-04-23 22:37:11
解法1 #include <algorithm> #include <cstdio> #include <cmath> #include <iostream> using namespace std; int main(){ int n, x, 展开全文
头像 YangWenhao
发表于 2022-05-30 16:10:58
代码 注意:cpp中除法为向下取整, 导致结果偏小 如第13行, 可以在等式两边都乘以3即可 #include <iostream> #include <cstdio> using namespace std; int main(){ int n; sca 展开全文
头像 立志实干
发表于 2021-06-01 13:37:59
#include <iostream> #include <cstdio> using namespace std; int main(){ int n; while(scanf("%d",&n)!=EOF){ int x,y,z 展开全文
头像 渺小小螃蟹
发表于 2021-05-07 16:08:31
include <stdio.h> main(){ int x,y,z,n; scanf("%d",&n); for(x=0;x<=100;x++) { for(y=0;y<=100;y++) { 展开全文
头像 IAMCKAI
发表于 2022-03-22 22:51:58
进行除法运算时,需注意小数。 #include <iostream> #include <cstdio> using namespace std; void chicken(int money){ for(int i = 0; i<=100; i++){ 展开全文
头像 奔放的芭乐在做ppt
发表于 2023-04-15 22:36:33
#include<cstdio> #include<iostream> using namespace std; int main() { int n; cin>>n; int a,b,c; for(a=0;a<=100;a++) { fo 展开全文
头像 牛客861440576号
发表于 2023-02-08 20:38:22
#include <iostream> int main() { int n; // 100 只鸡 // 5元 大鸡 x // 3元 小鸡 y // 1/3元 鸡娃 z while (EOF != scanf("%d", &n 展开全文
头像 zoey447
发表于 2022-01-23 15:47:08
"> using namespace std; int main(){ int x,y,z; int n, temp; cin >> n; if(n < 100/3) cout << "钱太少了" << endl; for(x=0; x< 展开全文
头像 乌龟狗的齐天大圣
发表于 2023-02-15 15:33:59
#include <stdio.h> int main(){ int n; int x,y,z; int z1=0; while(scanf("%d",&n) != EOF){ for (x=0;x<=100;x++){ 展开全文
头像 牛客440904392号
发表于 2024-10-03 01:39:33
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n 展开全文