当前位置:网站首页>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
边栏推荐
- MySql分组查询规则
- There is no index in the database table. When inserting data, SQL statements are used to prevent repeated addition (Reprint)
- Unity knowledge points (ugui 2)
- 关于idea调试模式下启动特别慢的优化
- Charles uses three ways to modify requests and responses
- 2022 团体程序设计天梯赛 模拟赛 L2-3 浪漫侧影 (25 分)
- Chapter 8 of C language programming (fifth edition of Tan Haoqiang) is good at using pointer exercises to analyze and answer
- Idempotency practice operation, explaining idempotency based on business
- JS inheritance
- PWA I'm here
猜你喜欢

2022 团体程序设计天梯赛 模拟赛 L2-1 盲盒包装流水线 (25 分)

Test questions and some space wars

关于idea调试模式下启动特别慢的优化

Experiment 6 input / output stream

Basic use of Charles
![Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]](/img/1a/a22b4a35d3c083438d0f766a5ecb08.png)
Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]

Test questions (2)

MySQL query specifies that a row is sorted to the first row

Is it difficult to choose binary version control tools? After reading this article, you will find the answer

12. < tag linked list and common test site synthesis > - lt.234 palindrome linked list
随机推荐
JS calculates the display date according to the time
Test questions (2)
MySQL keyword group_ Concat, combined connection query
超好用的【通用Excel导入功能】
MySQL之explain关键字详解
超好用的Excel异步导出功能
Why is bi so important to enterprises?
场景题:A系统如何使用B系统的页面
Iotos IOT middle platform is connected to the access control system of isecure center
Visual programming - Experiment 1
It can receive multiple data type parameters - variable parameters
Oracle query foreign keys contain comma separated data
打卡:4.23 C语言篇 -(1)初识C语言 - (12)结构体
Chapter 8 of C language programming (fifth edition of Tan Haoqiang) is good at using pointer exercises to analyze and answer
Translation of l1-7 matrix columns in 2022 group programming ladder Simulation Competition (20 points)
MySQL installation pit
How to achieve centralized management, flexible and efficient CI / CD online seminar highlights sharing
Advanced sorting - fast sorting
C interface
Punch in: 4.23 C language chapter - (1) first knowledge of C language - (12) structure