Stack Machine Executor

题目链接:

http://acm.hust.edu.cn/vjudge/problem/26628

Description


http://7xjob4.com1.z0.glb.clouddn.com/18113a5cf78f108997460e36f7079fc6

Input


The input contains several instances. Each instance consists of two lines, the first line is the encryption
key and the second line is the plaintext. Both key and plaintext consist of uppercase letters of the
English alphabet {A, B, C, . . . , Z}. The length of the key will be between 1 and 1000, the length of the
plaintext between 1 and 100 000, inclusive.
Input is terminated by a line containing one zero.

Output


For each input instance, output the ciphertext — the encrypted version of the message.

Sample Input


ICPC
THISISSECRETMESSAGE
ACM
CENTRALEUROPEPROGRAMMINGCONTEST
LONGKEY
CERC
0

Sample Output


CKYVRVIHLUUWVHIVJJU
DHAUUNMHHSRCFSEPJEBPZJQTDRAUHFU
OTFJ

Source


2016-HUST-线下组队赛-1


##题意:

用密钥来加密字符串.


##题解:

题目真是长,然而是签到题...
要练习一下快速读题了...不要看到长题面不敢读..
直接模拟即可.


##代码:
``` cpp
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define LL long long
#define eps 1e-8
#define maxn 101000
#define mod 100000007
#define inf 0x3f3f3f3f
#define mid(a,b) ((a+b)>>1)
#define IN freopen("in.txt","r",stdin);
using namespace std;

char str[maxn];

char key[maxn];

int main(int argc, char const *argv[])

{

//IN;

while(gets(key) && key[0] != '0')
{
gets(str); int klen = strlen(key);
int len = strlen(str); for(int i=0,j=0; i<len; i++,j++) {
if(j == klen) j = 0;
str[i] = (str[i] + key[j] - 'A' + 1 - 'A') % 26 + 'A';
} puts(str);
} return 0;

}

UVALive 5880 Vigenère Cipher Encryption (模拟)的更多相关文章

  1. Codeforces Round #528-A. Right-Left Cipher(字符串模拟)

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  2. 2018 ACM-ICPC 宁夏 C.Caesar Cipher(模拟)

    In cryptography, a Caesar cipher, also known as the shift cipher, is one of the most straightforward ...

  3. UVALive 7454 Parentheses (栈+模拟)

    Parentheses 题目链接: http://acm.hust.edu.cn/vjudge/contest/127401#problem/A Description http://7xjob4.c ...

  4. UVALive 7325 Book Borders (模拟)

    Book Borders 题目链接: http://acm.hust.edu.cn/vjudge/contest/127407#problem/B Description A book is bein ...

  5. Vigenère Cipher 维吉尼亚加解密算法

    维吉尼亚的加解密有两种方法. 第一种是查表:第一行为明文,第一列为密钥,剩余的为对应的密文 第二种方法是转化计算法:逐个将字符转化为从零开始的数字,对数字进行加密/解密后,再转化为字符. 本文要用c+ ...

  6. python实现维吉利亚密码加密(Vigenère cipher)

    最近有个朋友问我关于维吉利亚密码如何用python实现加密,研究之后发现这是个挺好玩的东西,遂决定写篇博文记录一下. 一.何谓维吉利亚密码 第一列是密钥字母列,第一行是明文字母行.不难看出维吉利亚密码 ...

  7. 80.Vigenère密码(模拟)

    Vigenère密码(文件名vigenere.cpp   vigenere.in    vigenere.out) 题目描述 Description 16 世纪法国外交家Blaise de Vigen ...

  8. UvaLive 4917 Abstract Extract (模拟)

    题意: 给定一篇文章, 文章中有段落, 段落中有句子. 句子只会以'!' , '.' , '?' 结尾, 求出每段中含有与他下面同样是该段落中相同单词数最多的句子, 注意, 单词忽略大小写, 重复的单 ...

  9. UVALive 5886 The Grille (模拟)

    The Grille 题目链接: http://acm.hust.edu.cn/vjudge/problem/26634 Description http://7xjob4.com1.z0.glb.c ...

随机推荐

  1. No resource found that matches the given name

    XML里面明显已经定义了ID,可是android:layout_toLeftOf="@id/text_seller"报错,说没有定义,原来这玩意要写在相对位置对象声明的下面,是有顺 ...

  2. ubuntu 12.04上安装OpenERP 7的一次记录

    登陆ssh, 先更新系统: sudo apt-get update && sudo apt-get dist-upgrade 接着再为openerp运行创建一个系统用户,用户名就叫op ...

  3. 一天一点MySQL复习——存储过程

    一.存储过程概念 使用SQL编写访问数据库的代码时,可用两种方法存储和执行这些代码,一种是在客户端存储代码,并创建向数据库服务器发送的SQL命令(或SQL语句),比如在C#.Java等客户端编程语言中 ...

  4. 【转】Eclipse+PyDev 安装和配置

    原文网址:http://www.51testing.com/html/67/589567-866611.html Python开发有很多工具,其中Eclipse+Pydev 是最常见的一种.本文简单介 ...

  5. Android AIDL SERVICE 双向通信 详解

    http://www.cnblogs.com/punkisnotdead/p/5062631.html 起因 是这个blog 提到了 用webview 的时候 用开启子进程的方式 可以极大避免内存泄露 ...

  6. Android 图文教学让你彻底理解activity启动模式

    我们首先从最简单的开始, standard 这个模式就是默认的模式,我们都知道 当你用这个模式时,每次发送一个intent,都会生成一个新的实例! 我写一个简单的例子: <?xml versio ...

  7. python numpy argsort函数用法

    numpy.argsort numpy.argsort(a, axis=-1, kind='quicksort', order=None)[source] Returns the indices th ...

  8. MySQL基础之第18章 性能优化

    18.1.优化简介 SHOW STATUS LIKE ‘value’;connections                 连接数uptime                          启动 ...

  9. 如何在MySql中记录SQL日志

    SQL server有一个sql profiler可以实时跟踪服务器执行的SQL语句,这在很多时候调试错误非常有用.例如:别人写的复杂代码.生产系统.无调试环境.无原代码... ...   查了一下资 ...

  10. 防范 DDoS 攻击的 15 个方法

    为了对抗 DDoS(分布式拒绝服务)攻击,你需要对攻击时发生了什么有一个清楚的理解. 简单来讲,DDoS 攻击可以通过利用服务器上的漏洞,或者消耗服务器上的资源(例如 内存.硬盘等等)来达到目的.DD ...