// 表示题目意思我是理解了蛮久 英语太水了 
//首先这是解密公式 m=c^d mod n
// 给你 p q e 然后 n=p*q fn=(p-1)*(q-1)
// 给你 e,根据公式 e*d mod fn =1 求出 d
// 然后有 L个数据要解密
// 算法:
// 扩展欧几里得 :求 d
// 快速幂运算 :解密
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;
#define maxm 100010
#define maxn 1000110
#define LL __int64
LL pow(LL a,LL b,int m){
LL t=;
for(;b>;b=b>>,a=(a*a)%m)
if(b&) t=(t*a)%m;
return t;
}
LL d,x,y;
void extendGcd(LL a,LL b){
if(b==){
d=a;
x=;
y=;
}
else{
extendGcd(b,a%b);
LL tp=x;
x=y;
y=tp-a/b*y;
}
}
int main()
{
int cc;
char ch;
LL p,q,e,l,fn,n;
while(scanf("%I64d %I64d %I64d %I64d",&p,&q,&e,&l)!=EOF){
fn=(q-)*(p-);
n=p*q;
extendGcd(e,fn);
while(x<) x+=fn/d;
//printf("%I64d",x);
while(l--){
scanf("%d",&cc);
ch=(char)(pow(cc,x,n));
printf("%c",ch);
}
printf("\n");
}
//printf("%I64d %I64d\n",x,y);
return ;
}

hdu 1211 RSA的更多相关文章

  1. hdu 1211 RSA (逆元)

    RSA Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...

  2. HDU 1211 EXGCD

    EXGCD的模板水题 RSA算法给你两个大素数p,q定义n=pq,F(n)=(p-1)(q-1) 找一个数e 使得(e⊥F(n)) 实际题目会给你e,p,q计算d,$de \mod F(n) = 1$ ...

  3. hdu 1211 逆元

    RSA Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...

  4. HDU 1211

    水.模拟即可.使用EXGCD求逆元 #include <iostream> #include <cstdio> #include <cstring> #includ ...

  5. HDU RSA 扩展欧几里得

    Problem Description RSA is one of the most powerful methods to encrypt data. The RSA algorithm is de ...

  6. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

  7. 基于OpenSLL的RSA加密应用(非算法)

    基于OpenSLL的RSA加密应用(非算法) iOS开发中的小伙伴应该是经常用der和p12进行加密解密,而且在通常加密不止一种加密算法,还可以加点儿盐吧~本文章主要阐述的是在iOS中基于openSL ...

  8. HDU——PKU题目分类

    HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...

  9. [转] HDU 题目分类

    转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...

随机推荐

  1. nenu contest2

    http://vjudge.net/vjudge/contest/view.action?cid=54562#overview H  B. Polygons http://codeforces.com ...

  2. 利用vim阅读源代码一个好用的工具

    阅读源代码时常常遇到找变量,函数定义的问题.vim为我们提供了一个好用的工具,ctags. 安装 ctags. 在 libvirt的源代码根目录运行 ctags -R . vim -t virConn ...

  3. ubuntu12.10+NDK r9 编译 ffmpeg 的一些参考资料Perhaps you should add the directory containing `libssl.pc'

    首先入门级的 编译宝典: https://trac.ffmpeg.org/wiki/CompilationGuide/Android http://www.roman10.net/how-to-bui ...

  4. 解决在windows的eclipse上面运行WordCount程序出现的一系列问题详解

    一.简介 要在Windows下的 Eclipse上调试Hadoop2代码,所以我们在windows下的Eclipse配置hadoop-eclipse-plugin- 2.6.0.jar插件,并在运行H ...

  5. Hadoop格式化HDFS报错java.net.UnknownHostException: localhost.localdomain: localhost.localdomain

    异常描述: 在对HDFS格式化,执行hadoop namenode -format命令时,出现未知的主机名的问题,异常信息如下所示: [shirdrn@localhost bin]$ hadoop n ...

  6. cygwin如何断点续传

    对于Cygwin,如果想安装的东西比较多的话,推荐先选择“Download without installing”,下载完了再从本地安装. 好了,说关于断点续传.我所知道的是—— 网上有说法:下载失败 ...

  7. Windows下gcc以及Qt的DLL文件调用之总结(三种方法)

    DLL与LIB的区别 :1.DLL是一个完整程序,其已经经过链接,即不存在同名引用,且有导出表,与导入表lib是一个代码集(也叫函数集)他没有链接,所以lib有冗余,当两个lib相链接时地址会重新建立 ...

  8. AE CreateFeatureClass 创建shp. 删除shp. 向shp中添加要素

    /// <summary> /// 创建多边形shp /// </summary> /// <param name="pPolygon">< ...

  9. Entity Freamwork 6连接PostgreSql数据库

    原文 Entity Freamwork 6连接PostgreSql数据库 开发环境 VS 2015  Update 1   Postgre Sql 9.4 使用过程 1.使用Nuget在项目中添加对E ...

  10. Easyui 中的placeholder属性

    在 easyui有文档中,没注意还真找不到placeholder属性,因为在属性只在searchbox中提到了, <input id="ss" class="eas ...