#P5596. Counting Natural Number Pairs

    ID: 18826 Type: Default 1000ms 256MiB

Counting Natural Number Pairs

Counting Natural Number Pairs

Let a and b be two given natural numbers. Find the number of pairs of natural numbers (x, y) that satisfy the equation:

$$y^2 - x^2 = ax + b$$

If there exist infinitely many such pairs, output inf.

Note: In this problem, natural numbers are assumed to be nonnegative integers.

inputFormat

The input consists of a single line containing two natural numbers a and b separated by a space.

outputFormat

Output a single integer denoting the number of pairs (x, y) satisfying the equation. If there are infinitely many solutions, output inf instead.

sample

0 0
inf