Throwing eggs questions and looking for change problem algorithm (c) -------- throwing eggs questions and looking for change problem

Algorithm (c) -------- throwing eggs questions and looking for change problem

 

扔鸡蛋问题描述:You are given two eggs, and access to a 100-storey building. The aim is to find out the highest floor from which an egg will not break when dropped out of a window from that floor.

What strategy should you adopt to minimize the number of egg drops it takes to find the solution?

Looking for change Problem Description:

• When the system is 20 cents coin 5 minutes, 10 cents, 5 minutes, 1 time-sharing, to customers looking for 60 cents 3 cents, how do? Minimum number of coins out of
  - the optimal solution: 6 2 = angle of 3 minutes and a quarter of a 1 + 3 + 1 corner points, the optimal value of 6 Coins
  - Stage: Each ...
• state ( the size of sub-problems): the remaining amount
• decision: each angle in 2 5 minutes, 10 cents, 5 points, 1 point, select a face value does not exceed the maximum amount of the remaining coins
• when the coin system is 4 points, 3 points, 1 time-sharing, to customers looking for 6 cents, how do?
  - According to the above strategies, six points 4 points = 1 + 2 1 min, 3 Coins
  - 3 minutes and 2 is the optimal solution!

solution:

• selection of the composition. 6 ¢ minimum number of coins (1 ¢, 3 ¢, and 4 ¢)

Therefore, selection of the coin 1 ¢, 2 ¢, 3 ¢ , ..., 6 ¢
composition 1 ¢, ¢ may use only. 1 (1 coin)
composition 2 ¢, using 1 ¢ + 1 ¢ (1 coin + 1 coin = 2 coins)
composed of 3 ¢, using 3 ¢ coin (1 coin)
composition 4 ¢, using 4 ¢ coin (1 coin)
compositions. 5 ¢, the try
. 1 ¢ +. 4 ¢ (. 1 COIN +. 1 COIN = 2 coins)
2 ¢ + 3 ¢ (2 coins + 1 coin = 3 coins)
original problem: the composition. 6 ¢, the try
. 1 ¢ +. 5 ¢ (. 1 COIN + 2 Coins =. 3 Coins)
2 ¢ +. 4 ¢ (2 Coins +. 1 COIN =. 3 Coins)
3 ¢ + 3 ¢ (1 coin + 1 coin = 2 coins) ------> best solution

扔鸡蛋问题描述:You are given two eggs, and access to a 100-storey building. The aim is to find out the highest floor from which an egg will not break when dropped out of a window from that floor.

What strategy should you adopt to minimize the number of egg drops it takes to find the solution?

Looking for change Problem Description:

• When the system is 20 cents coin 5 minutes, 10 cents, 5 minutes, 1 time-sharing, to customers looking for 60 cents 3 cents, how do? Minimum number of coins out of
  - the optimal solution: 6 2 = angle of 3 minutes and a quarter of a 1 + 3 + 1 corner points, the optimal value of 6 Coins
  - Stage: Each ...
• state ( the size of sub-problems): the remaining amount
• decision: each angle in 2 5 minutes, 10 cents, 5 points, 1 point, select a face value does not exceed the maximum amount of the remaining coins
• when the coin system is 4 points, 3 points, 1 time-sharing, to customers looking for 6 cents, how do?
  - According to the above strategies, six points 4 points = 1 + 2 1 min, 3 Coins
  - 3 minutes and 2 is the optimal solution!

solution:

• selection of the composition. 6 ¢ minimum number of coins (1 ¢, 3 ¢, and 4 ¢)

Therefore, selection of the coin 1 ¢, 2 ¢, 3 ¢ , ..., 6 ¢
composition 1 ¢, ¢ may use only. 1 (1 coin)
composition 2 ¢, using 1 ¢ + 1 ¢ (1 coin + 1 coin = 2 coins)
composed of 3 ¢, using 3 ¢ coin (1 coin)
composition 4 ¢, using 4 ¢ coin (1 coin)
compositions. 5 ¢, the try
. 1 ¢ +. 4 ¢ (. 1 COIN +. 1 COIN = 2 coins)
2 ¢ + 3 ¢ (2 coins + 1 coin = 3 coins)
original problem: the composition. 6 ¢, the try
. 1 ¢ +. 5 ¢ (. 1 COIN + 2 Coins =. 3 Coins)
2 ¢ +. 4 ¢ (2 Coins +. 1 COIN =. 3 Coins)
3 ¢ + 3 ¢ (1 coin + 1 coin = 2 coins) ------> best solution

Guess you like

Origin www.cnblogs.com/cmybky/p/11776346.html