#P10320. 勇气(Courage)
勇气(Courage)
Background
Mathematicians’ virtue of seeking the beauty of truth, the source of unceasing strength — courage.
Joy, “Light of Courage”, is the succeeding chief of the Dwarf族 (Duwofu, pinyin), and also a warrior who possesses the power of the ancient God of War.
Problem Description
Joy has a skill that can strengthen an attack power of into . However, this skill is not perfect: except for the first time, before each use of the skill, the attack power will decay to half of the previous value.
For example, if the initial attack power is , after strengthening it becomes . Before the next strengthening, it will first decay to , and then be strengthened into .
Joy wants to know: if the initial attack power is , what is the minimum number of strengthenings needed to make it not less than ?
If no matter how many times it is strengthened, it is still impossible to meet the requirement, output inf.
Input Format
One line containing two positive integers , representing the initial attack power and the target attack power .
Output Format
Output one line with one integer or the string inf, representing the answer.
2 1
0
3 6
3
16 335
7
Hint
[Sample Explanation]
The initial attack power already reaches , so it satisfies the requirement without using the skill. Therefore the answer is .
[Sample Explanation]
The initial attack power is , and the target is . After the first use it becomes , after the second it becomes , and after the third it becomes , which already meets the requirement. Therefore the answer is .
[Constraints]
This problem uses bundled testdata.
Subtask 1 (15 pts): .
Subtask 2 (20 pts): .
Subtask 3 (25 pts): .
Subtask 4 (40 pts): no special constraints.
For all testdata: , .
Translated by ChatGPT 5