#P6634. [ZJOI2020] 密码
[ZJOI2020] 密码
Description
Bob likes Alice.
Alice and Bob want to communicate with encryption, so they designed an encryption algorithm for identity verification by themselves. You know that this encryption algorithm is not reliable, and you have intercepted the messages between Alice and Bob. Now you want to recover Alice’s secret key.
Alice and Bob agree on a large prime number , a random range value , and an integer secret key generated uniformly at random in . Among them, the values of and are public, while the value of is only known to Alice and Bob.
When Bob wants to verify Alice’s identity, Bob generates numbers uniformly at random in and sends them to Alice. For each , Alice returns to Bob the value of modulo . To prevent eavesdropping, Alice adds a disturbance uniformly at random in to to the result.
That is, Alice returns to Bob equations of the form , where is a non-public number generated uniformly at random in to , is a randomly generated number, and are public numbers.
You have obtained these equations returned by Alice (that is, pairs of and ). You need to find the value of .
Input Format
The first line contains an integer , which denotes the number of test cases.
For each test case, the first line contains three integers . The next lines each contain two integers . Their meanings are the same as in the statement.
Output Format
Output lines.
For each test case, output an integer between and as the answer. The testdata guarantees that a solution exists and the solution is unique.
见下发文件。该样例满足题目中提到的所有随机生成的性质。
Hint
For the first of the testdata, .
For the first of the testdata, .
For the first of the testdata, .
For the first of the testdata, .
For another of the testdata, and .
For of the testdata, , , , , , and it is guaranteed that is prime.
Translated by ChatGPT 5
京公网安备 11011102002149号