Algebra
Time limit5sMemory limit1024 MB
Count integer pairs (a, b) with |a|, |b| <= m such that x^n + a*x + b = 0 has exactly k distinct rational roots.
- Level
Medium6 of 10
- Topics
- Math, Number theory, Combinatorics
- Solved
- No attempts yet
Problem
Given three integers , , and , find the number of pairs that satisfy all of the following conditions.
- , that is, and are integers
- , where is the set of rational roots of the equation and is the size of . In other words, the equation has exactly distinct rational numbers as solutions.
A number is rational if and only if there exist integers and with such that .
Input
The input consists of several test cases, terminated by end-of-file. The first line of each test case contains three integers , , and .
Output
For each test case, output one integer, the number of pairs.
Constraints
- In each input, the sum of does not exceed .
Hint
For the first test case, only the equation has one rational root.
For the second test case, each of the following 7 equations has two distinct rational roots: , , , , , , .