A Two Vessels
You have two vessels with water. The first vessel contains $a$ grams of water, and the second vessel contains $b$ grams of water. Both vessels are very large and can hold any amount of water.
You also have an empty cup that can hold up to $c$ grams of water.
In one move, you can scoop up to $c$ grams of water from any vessel and pour it into the other vessel. Note that the mass of water poured in one move does not have to be an integer.
What is the minimum number of moves required to make the masses of water in the vessels equal? Note that you cannot perform any actions other than the described moves.
思路
数学题,但是要注意数据类型均为小数
代码
1 |
|
B 游游的字符重排
You are in a corridor that extends infinitely to the right, divided into square rooms. You start in room $1$, proceed to room $k$, and then return to room 1. You can choose the value of $k$. Moving to an adjacent room takes $1$ second.
Additionally, there are $n$ traps in the corridor: the i-th trap is located in room $d_i$ and will be activated $s_i$ seconds after you enter the room $d_i$. Once a trap is activated, you cannot enter or exit a room with that trap.
A schematic representation of a possible corridor and your path to room $k$ and back.
Determine the maximum value of $k$ that allows you to travel from room $1$ to room $k$ and then return to room $1$ safely.
For instance, if n=1 and $d_1=2,s_1=2$, you can proceed to room $k=2$ and return safely (the trap will activate at the moment $1+s_1=1+2=3$, it can’t prevent you to return back). But if you attempt to reach room $k=3$, the trap will activate at the moment $1+s_1=1+2=3$ preventing your return (you would attempt to enter room 2 on your way back at second 3, but the activated trap would block you). Any larger value for k is also not feasible. Thus, the answer is $k=2$.
思路
见注释,懒了(
代码
1 |
|