#P5451. [THUPC 2018] 密码学第三次小作业
[THUPC 2018] 密码学第三次小作业
Description
Now there are two users who, by coincidence, have the same modulus but different private keys. Let their public keys be and , and they are coprime. The plaintext message is , and the ciphertexts are:
$$\begin{matrix}c_1=m^{e_1}\bmod N\\c_2=m^{e_2}\bmod N\end{matrix}$$Now, an attacker has intercepted , , , , and . Please help him recover the plaintext .
Input Format
The input contains multiple test cases. The first line contains an integer indicating the number of test cases, and it is guaranteed that . Then each test case is described as follows:
- One line contains five positive integers , , , , . It is guaranteed that , has exactly two prime factors, and the other values are generated strictly according to the RSA algorithm described above.
Output Format
For each test case, output line:
- A non-negative integer . Please make sure that when outputting. It is guaranteed that the answer is coprime with .
1
1502992813 2511821915 653507 57809 2638352023
19260817
Hint
Copyright Information
From the 2018 Tsinghua University Programming Contest and Intercollegiate Invitational (THUPC2018). Thanks to Pony.ai for supporting this contest.
Solutions and other resources can be found at https://github.com/wangyurzee7/THUPC2018.
Translated by ChatGPT 5
京公网安备 11011102002149号