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.
Description
Joy has a skill that can strengthen an attack power of $x$ into $x^2$. 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 $\color{red}6$, after strengthening it becomes $6^2=\color{red}{36}$. Before the next strengthening, it will first decay to $36/2=18$, and then be strengthened into $18^2=\color{red}{324}$.
Joy wants to know: if the initial attack power is $x$, what is the minimum number of strengthenings needed to make it **not less than** $2^n$?
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 $x,n$, representing the initial attack power $x$ and the target attack power $2^n$.
Output Format
Output one line with one integer or the string `inf`, representing the answer.
Explanation/Hint
[Sample $1$ Explanation]
The initial attack power $x=2$ already reaches $2^n=2$, so it satisfies the requirement without using the skill. Therefore the answer is $0$.
[Sample $2$ Explanation]
The initial attack power is $3$, and the target is $2^6=64$. After the first use it becomes $9$, after the second it becomes $(9/2)^2=81/4$, and after the third it becomes $((81/4)/2)^2=6561/64$, which already meets the requirement. Therefore the answer is $3$.
[Constraints]
**This problem uses bundled testdata.**
Subtask 1 (15 pts): $n\le 60$.
Subtask 2 (20 pts): $x=4$.
Subtask 3 (25 pts): $n\le 10^5$.
Subtask 4 (40 pts): no special constraints.
For all testdata: $2\le x\le 10^9$, $1\le n \le 10^9$.
Translated by ChatGPT 5