#P5596. 【XR-4】题

【XR-4】题

Description

X encountered a problem:

Given natural numbers a,ba, b, find the number of pairs of natural numbers (x,y)(x, y) that satisfy:

y2x2=ax+by^2 - x^2 = ax + b

He cannot solve it, so he asks you, who are good at math, for help.

If there are infinitely many pairs of natural numbers that satisfy the condition, you only need to output inf.

Input Format

One line with two integers a,ba, b.

Output Format

If the number is finite, output one integer in one line, representing the count.

If the number is infinite, output one string inf in one line.

5 15

1

4 4

inf

12 6

0

96 96

7

10000 9999997

6

Hint

Sample #1 Explanation

(x,y)=(6,9)(x,y) = (6,9)

Constraints

This problem uses bundled testdata.

  • Subtask 1 (3 points): a=b=0a = b = 0.
  • Subtask 2 (6 points): 0a,b20 \le a,b \le 2, there is no case with an infinite number of solutions.
  • Subtask 3 (9 points): 0a,b1000 \le a,b \le 100, there is no case with an infinite number of solutions.
  • Subtask 4 (13 points): 0a,b1030 \le a,b \le 10^3, there is no case with an infinite number of solutions.
  • Subtask 5 (14 points): 0a1040 \le a \le 10^4, 0b1070 \le b \le 10^7.
  • Subtask 6 (14 points): a=0a = 0.
  • Subtask 7 (14 points): b=0b = 0.
  • Subtask 8 (27 points): no special constraints.

For 100%100\% of the testdata, 0a1080 \le a \le 10^8, 0b10150 \le b \le 10^{15}.

Translated by ChatGPT 5