HDU 1211(RSA)

根据题意暴力破解即可。

#include <iostream>
using namespace std;

int main()
{
    int p, q, e, l;
    int c, d, m;
    __int64 n, fn;
    while (cin >> p >> q >> e >> l)
    {
        n = p * q;
        fn = (p - 1) * (q - 1);
        int i = 0;
        while ((i * fn + 1) % e != 0)
        {
            ++i;
        }
        d = (i * fn + 1) / e;
        for (int i = 0; i < l; i++)
        {
            cin >> c;
            m = 1;
            for (int j = 1; j <= d; j++)
            {
                m = (m * c) % n; //避免溢出
            }
            cout << (char)m;
        }
        cout << endl;
    }
    return 0;
}

继续加油。

发布了138 篇原创文章 · 获赞 1 · 访问量 7001

猜你喜欢

转载自blog.csdn.net/Intelligence1028/article/details/104634479
hdu
RSA
今日推荐