当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2466:Cryptography Reloaded

题目描述
What do researchers working at ICPC (Institute for Cryptographic Programming and Computing) do for fun? Well, as you probably have expected, in addition to solving algorithm-related problems on online judges, they also like to toy with various cryptographic schemes. Recently one of the researchers, Tom, has become interested in RSA algorithm implementations used in handheld devices.
Note that the description of the general RSA algorithm is as follows:
1) Choose two distinct prime numbers p and q, and let n = pq;
2) Choose an integer e such that gcd(e , (p-1)(q-1)) = 1;
3) Compute the integer d that satisfies the congruence relation
.
de ≡ 1 (mod (p-1)(q-1))
Then, if person A wants to give person B a way to send an encrypted message to him, A can follow the above steps and release (n, e) as his public key. Upon receiving A’s public key, B can simply encrypt message x (0 ≤ x < n) by computing y ≡ xe mod n . This would result in a message which ideally only A could decrypt with his private key d: x ≡ yd mod n .
As the computation power of handheld devices is usually limited, a relatively
small e is usually used to encrypt data. However this can lead to great security risks.
For example, it is quite simple to recover p and q (i.e., factor n) when you have both the public key (n, e) and the private key d. Could you help Tom write a program to demonstrate this?
输入解释
There are multiple test cases in the input file.
Each test case contains three integers, n, d, and e (n ≤ 10100 , 3 ≤ e ≤ 31 ). All three integers are given without any preceding zeros. It is guaranteed that all numbers satisfy the condition as given in the problem statement.
Two successive test cases are separated by a blank line. A case with n = 0, d = 0 and e = 0 indicates the end of the input file, and should not be processed by your program.
输出解释
For each test case, please print two prime numbers, p and q, such that n = pq and p < q, in the format as illustrated below.
输入样例
55 27 3
290203 168101 5
0 0 0
输出样例
Case #1: 5 11
Case #2: 29 10007
来自杭电HDUOJ的附加信息
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-2466

最后修改于 2020-10-25T22:53:41+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
5000/2000MS(Java/Others) 32768/32768K(Java/Others)