Nộp bài | Các bài nộp | Làm tốt nhất | Về danh sách bài |
DPEQN - Congruence Equation |
English | Vietnamese |
Given a congruence equation:
a1x1 + ... a2x2 + ... + anxn = b (mod m)
In which, a1, a2, ..., an, b and m are positive integer constants; x1, x2, ..., xn are unknowns.
Find a solution for this equation, or show that the equation has no solution.
Input
First line: number of test cases. Each test case has the following form:
- Line 1: n (1 ≤ n ≤ 100)
- Line 2: n integers a1, a2, ..., an (1 ≤ ai ≤ 108)
- Line 3: b, m (1 ≤ b, m ≤ 108)
Each test case is separated by a blank line.
Output
For each test case, if the equation has no solution, print "NO". Otherwise, print n integers x1, x2, ..., xn (0 ≤ xi < m) that is one solution to the equation.
Example
Input 2 2 4 6 6 10 2 4 6 3 8 Output 1 2 NO
Được gửi lên bởi: | Jimmy |
Ngày: | 2008-10-18 |
Thời gian chạy: | 1s |
Giới hạn mã nguồn: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Ngôn ngữ cho phép: | Tất cả ngoại trừ: ERL GOSU JS-RHINO NODEJS PERL6 PYPY RUST SED VB.NET |
Nguồn bài: | © VNOI |