Processing math: 100%
祝同学们学习进步,编程快乐!

Problem E: Equation

"
Time Limit 1 秒/Second(s) Memory Limit 512 兆字节/Megabyte(s)
提交总数 0 正确数量 1
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签 数学 数论
CO-CO met Prophet and invited him to join his team. But Prophet didn’t want his boss be just a sailor. So Prophet proposed a relatively popular question – “quadratic equation”. Prophet said he would stay if CO-CO can solve the problem. Fortunately CO-CO solved it quickly. But Prophet seemed very unhappy with his pride, so he added a condition:



X is the minimum non-negative integer which satisfied the above equation.
Can you help poor CO-CO to solve the problem under the new condition?
The input includes several cases. For each case, there is only one line contain A,B,C and p. (-200000000<A, B, C, p<200000000,and p is a prime)
For each case, output a single integer x. If the equation has no solution, just output -1.

1 -2 1 7
0 1 -1 13
1
1
Random Algorithm
AOJ
祝同学们学习进步,编程快乐!