当前位置:网站首页>Blue Bridge Cup - 2012b Group real question 3 specific drinking capacity
Blue Bridge Cup - 2012b Group real question 3 specific drinking capacity
2022-06-12 00:59:00 【I ~】
Blue Bridge Cup ——2012B Group 3 Than the amount of alcohol
Title Description
There's a group of pirates ( Not more than 20 people ), Compete for alcohol on board . The process is as follows : Open a bottle of wine , Everyone present shared the drink equally , Several people fell down . Open another bottle and divide it equally , There's another one down , Repeat... Again ---- Until the second time 4 A bottle of wine , There is little left to sit , The pirate captain is among them . When the first 4 After a bottle of wine is divided equally , Everyone fell . When the captain wakes up , The pirate ship was found stranded . He wrote in the log that :“… yesterday , I just drank a bottle … I advise you to , Sailing without drinking , Drink and don't sail …”
Please use this information , Infer how many people started , How many people are left after each round of drinking . If there are multiple possible answers , Please list all the answers , Each answer takes up one line . The format is : The number of , The number of ,…
for example , One possibility is :20,5,4,2,0
The code is as follows
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
// Here the violent solution is used
for(int n1=20;n1>4;n1--){
// There must be at least four people in the first round , To finish four rounds
for(int n2=n1-1;n2>3;n2--){
// Every round someone fell , So at least one person fell
for(int n3=n2-1;n3>2;n3--){
for(int n4=n3-1;n4>1;n4--){
if(fabs((1.0/n1+1.0/n2+1.0/n3+1.0/n4)-1)<=1e-5){
// Except integer zero , Floating point numbers are imprecise when they represent zero , It is not accurate from the decimal place , So it depends on whether this number is small enough , To a certain extent, it can be regarded as 0 了
cout<<n1<<" "<<n2<<" "<<n3<<" "<<n4<<" 0"<<endl;
}
}
}
}
}
return 0;
}
边栏推荐
- Introduction to semantic vector retrieval
- 2022 edition of global and Chinese hexamethylene chloride industry dynamic research and investment prospect forecast report
- 出门带着小溪
- C language pointer and array - learning 23
- Intel trimbert: tailor Bert for trade-offs
- [answer] business use cases and system use cases are mixed together
- 2022-06-11:注意本文件中,graph不是邻接矩阵的含义,而是一个二部图。 在长度为N的邻接矩阵matrix中,所有的点有N个,matrix[i][j]表示点i到点j的距离或者权重, 而在二部
- System.CommandLine选项Option
- One article to show you how to understand the harmonyos application on the shelves
- QApplication a (argc, argv) and exec() in the main function of QT getting started
猜你喜欢

Equipment encryption of industrial control security

Redis advanced - correspondence between object and code base

Bgfx multithreaded rendering

一、Flutter 入门学习写一简单客户端

【ROE】(2)ROE协议

What are the software development processes of the visitor push mall?

System. Commandline option

Argodb 3.2 of star ring technology was officially released to comprehensively upgrade ease of use, performance and security

Detailed explanation of merge sorting

One article to show you how to understand the harmonyos application on the shelves
随机推荐
C language string and pointer - learning 25
Lambda终结操作forEach
Lambda intermediate operation skip
Some suggestions on writing code to reproduce the paper!
What is bonded warehouse and what is the difference between them
Dr. wangxiting: understanding interpretable recommendation from the perspective of knowledge map and natural language generation
Online Fox game server - room configuration wizard - component attribute and basic configuration assignment
Exploration of qunar risk control safety products
Is interface automation difficult? Take you from 0 to 1 to get started with interface automation test [0 basic can also understand series]
Lambda create stream
Devops landing practice drip and pit stepping records - (1)
Nat. Comm. | 超算+AI: 为天然产物生物合成路线规划提供导航
Streaming data warehouse storage: requirements and architecture
Flutter uses local pictures
Equipment encryption of industrial control security
Lambda intermediate operation limit
repeat_ L2-009 red envelope grabbing_ sort
Global and Chinese nonene market operation research and future prospect forecast report 2022 ~ 2028
Lambda中间操作skip
C language preprocessing instructions - learning 21