f Naturaliser
By Kay Akashi
Time: 1000 ms
Memory: 256000 kB
The code judging system is only available during contests. Check out the
github repo for test cases and solutions.
Problem Statement
Given 6 positive integers a1, b1, c1, a2, b2, and c2, you will think of a function f(x)=a2x2+b2x+c2a1x2+b1x+c1.
Your task is to find all x such that f(x) is a positive integer. (x is an integer). 0 is not a positive integer.
It is ensured that a1<a2.
Constraints
1≤a1,b1,c1,a2,b2,c2,≤10.
a1<a2.
Input
The input consists of 6 integers, a1, b1, c1, a2, b2, and c2, in a single line.
Output
List the possible x in one line, in an increasing order. If there's no such x, output "None" instead.
Examples
Input
Output
Explanation
f(x)=4x2+9x+33x2+5x+8.
f(−5)=1, f(−2)=10, and f(1)=2. No other value satisfies the condition.
Input
Output
Explanation
It is only x=0 that makes f(x) a positive integer, which is 1.
Input
Output
Explanation
Be aware that some types of f(x) don't have any x that makes it a positive integer number. In this case, output "None".