means B saw someone with a black hat, while, B sees that everyone except himself is the same, that is, all wearing white hats. A thinks: B must have seen himself wearing black hats. Similarly, B will think like this, so when the lights are turned off for the second time, AB will beat itself ,..., In this case, N people wear black hats if a slap in the face appears after the light is turned off n times.
For question 4, see: http://www.oursci.org/archive/magazine/200111/011111.htm
【Optimization]
Yu Minhong's four bottles of water
There is a bottle of water in front of us because it is a good thing and everyone wants it. In order to get this bottle of water, I ran forward, and someone else took the water before I was about to catch it. But I still want to move forward, and there is a basket of flowers waiting for me. Of course, when I walked to the front of the flowers, it may have been taken away a
A beer on the market, 2 yuan per bottle, 4 caps can be exchanged for a bottle of beers, two empty beer can also be exchanged for a bottle of beer. How many bottles can I drink when I finish entering money?1#include 2 3 voidMain ()4 {5 intMoney,bottle_top,empty_bottle0,empty_bottle;6 intbottle=0;//prevent non-normal output7 8printf"Please enter the amoun
1. There are two kettles, one can hold 5 liters of water, and the other can hold 3 liters of water. How can I hold 4 liters of water in a 5 litre kettle ??
A: First fill the three-litre water bottle with water, pour the water into the five-litre water bottle, then fill the three-litre water bottle with water, and then pour it into the five-litre water
2257: [Jsoi2009] bottle and fuel time
limit:10 Sec Memory limit:128 MB
DescriptionJyy has been thinking of returning to Earth as soon as possible, but his ship's fuel is not enough.One day he went to the Martians to fuel, this time the Martians promised to jyy with the ship's bottles to change. JyyOn the ship there are N bottles (1After handing K bottles to the Martians, the Martians used them to put some fuel into the jyy. All the bottles h
A few days ago interviewed a company, gave two algorithm topics. Thought it was very interesting, when the interview answer when the answer is not very good. Then came back to find the information. Record it.First, the topic oneThere are 1000 bottles of water, one of which is poisonous, and the mice will die 24 hours after tasting a little poisonous water, at least how many mice can identify the bottle of water in 24 hours. Landlord this topic at that
this year I met in the written interview of three companies including 360, summed up the question of two methods and ingenious solutions, to facilitate the recruitment or when an intellectual problem to start thinking. Ask one: Three empty bottles for a bottle of soda, a class bought 30 bottles of soda, to ensure that each person drink a bottle of soda, up to how many students? Ask two: Three empty bottles
/*** A total of 1000 bottles of soda, did not finish a bottle to get an empty bottle, every 3 empty bottles can change 1 bottles of soda, drink and then get an empty bottle, ask how many bottles of soda, and finally how many empty bottles*/ Public Static voiddrink () {intnum = $, empty = 0, total = 0; while(num > 0) {num--;//drink a
DescriptionJyy has been thinking of returning to Earth as soon as possible, but his ship's fuel is not enough.One day he went to the Martians to fuel, this time the Martians promised to jyy with the ship's bottles to change. JyyOn the ship there are N bottles (1After handing K bottles to the Martians, the Martians used them to put some fuel into the jyy. All the bottles have no scale, onlyThe volume is marked at the bottle, and the volume of the I
functionality that your users need, instead of doing a bunch of useless things to users, identify and optimize usability issues as early as possible before product development, such as the prototype design phase, and reduce the risk of failure due to not understanding the requirements properly; Minimizing or eliminating documents can also reduce expenses.
Ii. 4 Dimensions of usability assessment
Functional functionality: Whether the product is useful. For example,
Ing is a very simple and practical mathematical technique that can often achieve clear results.
Ing to integers is frequently used.
Simple ing of discrete values is relatively trivial. If the ing can be combined with sequences, it can be very extraordinary.
For example, I have recently asked a question: 1000 bottles of water, one of which is toxic. When a white mouse dies after drinking for a week, how many white mice can find the bottle of water with
problem: one bottle contains one bacteria. bacteria are split once a minute, 1 change 2 , 60 the bottle will be full in minutes. How long will it take to fill the bottle with two bacteria?
first, we use a guess, not 30 59 , it cannot be other answers. If you want me to 30 and 59 select an answer, I will definitely choose 59 , impossib
Time Limit: 3.000 secondsTime Limit: 3.000 seconds
Background
Background
Bin packing, or the placement of objects of certain weights into different bins subject to certain constraints, is an historically interesting problem. some bin packing problems are NP-complete but are amenable to dynamic programming solutions or to approximately optimal heuristic solutions.The packing problem is that how to put objects of different weights into different boxes under certain constraints is an interes
had n buckets in front of us, one in each bucket, and now the numbers are out of order, we don't move the buckets, we sort the numbers out. we numbered n buckets from left to right, respectively, from 0 to N-1 .ok!!! Please follow my steps Oh ~ Don't fall behind!! 1 Take the number of bucket No. 0 in your hand, and this number, we'll use it as the base number, mid .2 Take a name called the high water bottle as a marker, from the right n-1 bucket to t
Method One:
Program:
#include
int main ()
{
int i=0;//i means money
int j=0;//j = Empty Bottle
int Sum=0;//sum drink Soda total bottle number
scanf ("%d", i);
Sum=i;
J=i;
while (j>=2)
{
SUM=SUM+J/2;
J=J%2+J/2;
}
printf ("%d\n", sum);
return 0;
}
Method two: (optimization)
Program:
#include
int main ()
{
int i=0;//i means money
int j=0;//j = Empty Bottle
int Su
of bottle movements. You shoshould also print the minimum number of bottle movements.
The output shoshould consist of a string of the three upper case characters 'G', 'B', 'C' (representing the colors green, brown, and clear) representing the color associated with each bin.
The first character of the string represents the color associated with the first bin, the second character of the string represents th
DescriptionJyy has been thinking of returning to Earth as soon as possible, but his ship's fuel is not enough. one day he went to the Martians to fuel, this time the Martians promised to jyy with the ship's bottles to change. Jyyon the ship there are N bottles (1after handing K bottles to the Martians, the Martians used them to put some fuel into the jyy. All the bottles have no scale, onlyThe volume is marked at the bottle, and the volume of the I
Question: There are n bottles of water, one of which is highly toxic. If the mouse drinks it, it will die 24 hours later.
Q: How many mice can detect which bottle of water is highly toxic?
Requirement: the number of mice used is small and the time should be short, and a reasonable process and conclusion should be given.
My solutions are as follows:
This is a binary switch (0/1) Problem, similar to the Haiming code Verification AlgorithmThe potion is
Problem K. Kitchen RobotTime Limit:1 SecMemory limit:256 MBTopic Connection http://codeforces.com/gym/100610DescriptionRobots is becoming more and more popular. They is used nowadays not only in manufacturing plants, but also at home. One programmer with he friends decided to create their own home robot. As know most programmers like to drink beer when they gather together for a party. After the party there is a lot of empty bottles left on the table. So, it is decided to program robot to collec
In C + +, we can also integrate functions with the same function to a function, without having to write several functions of different function names, which is called the overload of the function. The following is a detailed analysis of the function overload in C + +, the need for friends can come to refer to the next
When we open bottles and jars, we often encounter the embarrassment of finding the right tool because of different bottle sizes. So so
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.