#P4358. [CQOI2016] 密钥破解
[CQOI2016] 密钥破解
Description
The key generation process of an asymmetric encryption algorithm is as follows:
- Choose two distinct prime numbers .
- Compute , .
- Select an integer that is less than and coprime with .
- Compute an integer such that .
- The ordered pair is called the public key, and the ordered pair is called the private key.
When encrypting a message (assume is an integer less than , because any format of message can be converted to an integer), use the public key and compute
to obtain the ciphertext .
To decrypt the ciphertext , use the private key and compute
to obtain the original plaintext . The proof of correctness is omitted.
Because ciphertext encrypted with the public key can only be decrypted with the corresponding private key, and not with the public key itself, this is called an asymmetric encryption algorithm. Typically, the public key is published by the message receiver, while the private key is kept by the receiver. In this way, anyone can encrypt messages using the public key, but only the receiver can decrypt them.
Now your task is to find a feasible method to crack this encryption algorithm: derive the private key from the public key and then use it to decrypt the ciphertext.
Input Format
The input contains a single line with three positive integers separated by spaces.
Output Format
Output a single line with two integers separated by a space.
3 187 45
107 12
Hint
- For of the testdata, .
- For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号