Solve the equation in integers: (ax + b) / (cx + d) = 0
Input format
Enter 4 numbers: a, b, c, d; c and d are not equal to zero at the same time.
Output format
All solutions should be printed if their number is finite, “NO” (without quotes) if there are no solutions, and “INF” (without quotes) if there are infinitely many solutions.
Test 1
Input data:
1
1
2
2
Program output:
NO
Test 2
Input data:
2
-4
7
1
Program output:
2
Help me write Python code
Answer 1, authority 100%
a, b, c, d = int (input ()), int (input ()), int ( input ()), int (input ())
if a == 0 and b == 0:
print ('INF')
elif a == 0 or b * c == a * d:
print ('NO')
elif b% a == 0:
x = -b // a
print (x)
else:
print ('NO')