Линейный чёрный ящик
Hard
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
There is a linear function of two arguments f(x, y) = ax + by + c, where the coefficients a, b, c are unknown. According to N values of f(x_1, y_1) = d_1, ..., f(x_N, y_N) = d_N is required to determine uniquely the function f(u, v) or indicate that it is impossible.
Note that uniquely restore the function itself is not required. It is guaranteed that the function f exists.
Input
The input file contains integersN u v, followed by N triples of integers x_i y_i d_i.
Output
Output file must contain a unique integer f(u, v) any two numbers 0 (zero) if the unambiguous identification impossible.
1 ≤ N ≤ 100, −10^6 ≤ x_i, y_i, d_i ≤ 10^6, the coefficients a, b, c — integer.
Examples
Input #1
Answer #1
Submissions 81
Acceptance rate 2%