// 表示题目意思我是理解了蛮久 英语太水了 
//首先这是解密公式 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. Download Manager

    从Android 2.3(API level 9)开始Android用系统服务(Service)的方式提供了Download Manager来优化处理长时间的下载操作.Download Manager ...

  2. [SQL Server系] -- 视图

    1:定义 从用户角度来看,一个视图是从一个特定的角度来查看数据库中的数据. 从数据库系统内部来看,一个视图是由SELECT语句组成的查询定义的虚拟表. 从数据库系统内部来看,视图是由一张或多张表中的数 ...

  3. 重写equals()方法时,需要同时重写hashCode()方法

    package com.wangzhu.map; import java.util.HashMap; /** * hashCode方法的主要作用是为了配合基于散列的集合一起正常运行,<br/&g ...

  4. BZOJ 3198 SDOI2013 spring

    为什么SDOI省选一年考两次容斥原理? 我们很容易发现>=k个相等时很好计算的 但是我们要求恰好k个,那么我们容斥即可 至于计算>=k个相等,首先我们枚举相等位置,对每个串对应位置做一遍h ...

  5. [topcoder] EllysNumberGuessing

    http://community.topcoder.com/stat?c=problem_statement&pm=12975 简单题 #include <cstdlib> #in ...

  6. Android:密码显示隐藏

    效果: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android= ...

  7. Android 对话框弹出位置和透明度的设置

    在Android中 我们经常会用AlertDialog来显示对话框.通过这个对话框是显示在屏幕中心的.但在某些程序中,要求对话框可以显示在不同的位置.例如,屏幕的上 方或下方.要实现这种效果.就需要获 ...

  8. Java API —— IO流小结

    练习题: 1.复制文本文件 package cn.itcast_01; import java.io.BufferedReader; import java.io.BufferedWriter; im ...

  9. 一个zip压缩类,欢迎吐槽

    package com.utils; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import j ...

  10. 用matlab训练数字分类的深度神经网络Training a Deep Neural Network for Digit Classification

    This example shows how to use Neural Network Toolbox™ to train a deep neural network to classify ima ...