水。模拟即可。使用EXGCD求逆元

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define LL __int64
using namespace std; LL p,q,e,n,f,d; void exgcd(LL a,LL b,LL &x,LL &y){
if(b==0){
x=1; y=0;
return ;
}
exgcd(b,a%b,x,y);
LL tmp=x;
x=y;
y=tmp-(a/b)*y;
} LL quick(LL a,LL b,LL m){
a%=m;
LL ans=1;
while(b){
if(b&1)
ans=(ans*a)%m;
b>>=1;
a=(a*a)%m;
}
return ans;
} int main(){
LL l,num;
LL x,y;
while(scanf("%I64d%I64d%I64d%I64d",&p,&q,&e,&l)!=EOF){
n=p*q;
f=(p-1)*(q-1);
exgcd(e,f,x,y);
x=(x%f+f)%f;
for(LL i=1;i<=l;i++){
scanf("%I64d",&num);
int ans=(int)quick(num,x,n);
printf("%c",ans);
}
printf("\n");
}
return 0;
}

  

HDU 1211的更多相关文章

  1. 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$ ...

  2. hdu 1211 RSA

    // 表示题目意思我是理解了蛮久 英语太水了 //首先这是解密公式 m=c^d mod n// 给你 p q e 然后 n=p*q fn=(p-1)*(q-1)// 给你 e,根据公式 e*d mod ...

  3. hdu 1211 逆元

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

  4. hdu 1211 RSA (逆元)

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

  5. HDU——PKU题目分类

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

  6. [转] HDU 题目分类

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

  7. HDU ACM 题目分类

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

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

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

  9. hdu 1576 A/B(拓展欧几里得)

    A/B Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

随机推荐

  1. pythonWeb -- Django开发- Admin

    [第一次使用Admin 要创建超级用户账号] 1.\ python manage.py createsuperuser You have 1 unapplied migration(s). Your ...

  2. 【转】一分钟读懂互联网广告竞价策略GFP+GSP+VCG

    参考这篇文章: http://ju.outofmemory.cn/entry/116780 一分钟读懂互联网广告竞价策略GFP+GSP+VCG 两个广告位,三家广告主竞价,广告平台究竟应该制定广告竞价 ...

  3. iframe显示滚动栏

    子页面通过iframe载入.出现了竖向滚动栏 最后查出原因:文档申明 iframe有滚动栏的页面的文档申明 <!DOCTYPE html> 改成例如以下即可了 <!DOCTYPE H ...

  4. Oracle数据处理

    DML语言             &:地址符:(PrepareStament)             批处理:插入--------一次将10号部门的员工插入新的表中:           ...

  5. C#+HtmlAgilityPack+Dappe

    C#+HtmlAgilityPack+Dappe (转发请注明来源:http://www.cnblogs.com/EminemJK/) 最近因为公司业务需要,又有机会撸winform了,这次的需求是因 ...

  6. 内存问题检测神器:Valgrind

    Linux下内存问题检测神器:Valgrind 在写大型C/C++工程时难免会发生内存泄漏现象,系统编程中一个重要的方面就是有效地处理与内存相关的问题.你的工作越接近系统,你就需要面对越多的内存问题. ...

  7. 杂项-软件: VBA(Visual Basic for Applications)

    ylbtech-杂项-软件: VBA(Visual Basic for Applications) VBA (Visual Basic宏语言) Visual Basic for Application ...

  8. crawler4j多线程爬虫统计分析数据

    该事例演示了如何在多线程中统计和分析数据: 首先建一个状态实体类CrawlStat: package com.demo.collectingData; /** * 爬虫状态实体类 统计爬虫信息 * @ ...

  9. MVC 全局异常处理(适用多人操作)

    自定义特性: using System; using System.Collections.Generic; using System.Linq; using System.Web; using Sy ...

  10. Spring学习笔记(一) 简介

    版权声明 本文是摘自IBM上Naveen Balani的一篇文章,原文请点击此处:http://www.ibm.com/developerworks/cn/java/wa-spring1/ Sprin ...