I am trying to become a good guy, giving contestants as little pain as possible. So, this problem is very simple and easy, rejoice!
You will be given Q queries and an integer X. In each query, you will be given four integers A, B, C and M. For each query, you just have to find
where and .
Simple, right? Thank me later. 🙂
Input starts with two space-separated integers Q (1 ≤ Q ≤ 103) and X (1 ≤ X ≤ 109), in a single line.
Each of the following Q lines will represent a query, containing four space-separated integers A, B, C (0 ≤ A, B, C < M) and M (1 ≤ M ≤ 232) in each line.
For each query, print the answer in a single separate line as shown in the samples.
1 1 1 2 3 4
2 2 0 1 1 5 0 2 2 1000000
Login to submit
With an increased time limit of ~12s, the problem would be easily solvable using fast/binary exponen...