P28895 [洛谷] Rearrange DL
提高+
题目描述

Problem Background

The level order in Dancing Line is always mystical.

Problem Description

One day, Umaru came up with a new rule for ordering the levels in Dancing Line: Suppose a level is the $n$-th released level, then its position $a_n$ satisfies $a_{n+1}=(\sqrt[k]{a_n-n}+2)^k+n+1$, and the first released level is always at the first position, i.e., $a_1=2$.

However, this obviously leads to a problem: many positions are empty levels. Therefore, Umaru added a constraint: adjust $k$ such that the $n$-th level satisfies $a_n \equiv b\pmod{m}$. Now, Umaru provides $n, m, b$, and you need to find the smallest integer $k$ that satisfies the condition.

Input Format

The first line contains three numbers $n, m, b$.

Output Format

Output a single number, which is the smallest $k$; if no such $k$ exists, output INF.

Sample Input and Output

Sample Input #1

3 3 2

Sample Output #1

1

Sample Input #2

3 8 2

Sample Output #2

INF

Notes

For $30\%$ of the data, $n \le 100$, $0 \le b < m \le 10000$;

For $50\%$ of the data, $n \le 10^{12}$, $0 \le b < m \le 10000$;

For $100\%$ of the data, $n \le 10^{12}$, $0 \le b < m \le 10^{12}$.

It is guaranteed that $n, m, b$ are all positive integers.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 3 2
样例输出
1