当前位置:网站首页>A hundred dollars for a hundred chickens
A hundred dollars for a hundred chickens
2022-04-23 03:28:00 【Aiyou coffee】
If you just look at a hundred dollars to buy a hundred chickens , If you don't check it, you will look confused .
The premise of buying a hundred chickens for a hundred dollars is that the cock is a 5 element , A hen 3 element , The chicks are three for one yuan .
In fact, this code is a mathematical problem in the final analysis. You have to set the equation first , Let the cock have x only , The hen has y only , The chicken has z only .
x+y+z=100;5x+3y+z/3=100.
If there is 100 element , If you buy all the cocks, you can buy 20 only , If you buy all the hens, you can buy 33.33 That can be about 34 only , If you buy all the chickens, you can buy 300 only .
public class BuyChick{
public static void main(String[] args){
for(int x = 0; x<=20;x++){
for(int y =0;y<=34;y++){
for(int z =0;z<=300;z++){
if((x+y+z==100)&&((5*x+3*y+z/3)==100)&&(z%3==0)){
System.out.println(" cock "+x+"\t hen "+y+"\t Chick "+z);
}
}
}
}
}
}
If you buy a hundred chickens for a hundred dollars, just write it as above .
版权声明
本文为[Aiyou coffee]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220619009463.html
边栏推荐
- The fourth operation
- Node configuration environment CMD does not take effect
- 12. < tag linked list and common test site synthesis > - lt.234 palindrome linked list
- 月薪10k-20k都无法回答的事务问题,你会吗?
- L3-011 直捣黄龙 (30 分)
- Docker拉取mysql并连接
- Problem C: realize Joseph Ring with linked list
- The query type of MySQL is very inefficient.
- [mock data] fastmock dynamically returns the mock content according to the incoming parameters
- 打卡:4.22 C语言篇 -(1)初识C语言 - (11)指针
猜你喜欢
File upload vulnerability summary and upload labs shooting range documentary
浅学一下I/O流和File类文件操作
Super easy to use [general excel import function]
When migrating tslib_ setup: No such file or directory、ts_ open: No such file or director
Supersocket is Used in net5 - command
Basic use of Charles
L3-011 直捣黄龙 (30 分)
C interface
Romantic silhouette of L2-3 of 2022 group programming ladder Simulation Competition (25 points)
Supersocket is Use in net5 - concept
随机推荐
第四次作业
String input problem
POI create and export Excel based on data
MySql分组查询规则
浅学一下I/O流和File类文件操作
2022 group programming ladder simulation match 1-8 are prime numbers (20 points)
Explication détaillée des fonctions send () et recv () du programme Socket
Problem B: small challenge
How to achieve centralized management, flexible and efficient CI / CD online seminar highlights sharing
Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]
Knowledge of software testing~
MySQL installation pit
ThreadLocal 测试多线程变量实例
poi根据数据创建导出excel
月薪10k-20k都无法回答的事务问题,你会吗?
场景题:A系统如何使用B系统的页面
2022 group programming ladder simulation l2-1 blind box packaging line (25 points)
C abstract class
可以接收多種數據類型參數——可變參數
C-11 problem I: find balloon