#P4861. 按钮

    ID: 5731 远端评测题 280ms 125MiB 尝试: 0 已通过: 0 显示难度提高 上传者: 标签>数学枚举中国剩余定理 CRT

按钮

Background

Ada has been locked in a room.

Problem Description

On the room’s iron door, there is a button and a display showing “1”.
Next to it, there is a line of small text: “This is a high-precision base-MM calculator. Each time you press the button, the number on the screen will be multiplied by KK. When the last digit becomes 1 again, the door will open.”
Since Ada is eager to get out, you need to find the minimum number of button presses within 1 second.

Input Format

One line with two integers MM and KK.

Output Format

Output one number on one line, the minimum number of button presses.
If no matter how many times Ada presses the button the door cannot be opened, output "Let's go Blue Jays!" (without quotes).

11 2
10
6 26
Let's go Blue Jays!

Hint

For 30% of the testdata, 2M,K1042\leq M,K\leq10^4.
For 100% of the testdata, 2M,K2×1092\leq M,K\leq2\times 10^{9}.
Update: we do not consider numbers whose last digit is 11, 21, ... as valid solutions (for example, 11 is written as B in base 16).

Translated by ChatGPT 5