这题,类似密文解密的题目。题目的意思讲的很清楚。
给你p q e l,l为第二行的数字的个数。
先算出n和fn,在算出d。
n = p * q;fn = (p - 1)* (q - 1)。
再根据d * e % fn = 1,算出d。
最关键的是求M。给你的数c ,M等于c ^ d % n。M 对应的ASCLL码就是解密之后的字符。
下面的是AC的代码:
#include <iostream>
using namespace std;
int main()
{
int n, fn, p, q, e, l, num, d;
while(cin >> p >> q >> e >> l)
{
n = q * p;
fn = (p - 1) * (q - 1);
d = 1;
while(d * e % fn != 1)
d++;
for(int i = 0; i < l; i++)
{
cin >> num;
int c = 1;
for(int j = 1; j <= d; j++)
{
c = c * num;
c = c % n;
}
cout << (char)c;
}
cout << endl;
}
return 0;
}