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. View Transform(视图变换)详解

    http://www.cnblogs.com/graphics/archive/2012/07/12/2476413.html 什么是View Transform 我们可以用照相机的原理来阐释3D图形 ...

  2. ViewPager的监听事件失效

    主要是因为在我项目使用了PageIndicator,所以这个时候监听事件要写在PageIndicator上. mIndicator.setOnPageChangeListener(new OnPage ...

  3. C# Winform 获取天气情况

    WebServices(http://www.webxml.com.cn/WebServices/WeatherWebService.asmx)来实现天气预报,该天气预报 Web 服务,数据来源于中国 ...

  4. 【笨嘴拙舌WINDOWS】窗体样式

    "眼睛是人类心灵的窗口,打开窗口,你就能看到整个世界" 在PC时代,计算机的显示屏就是真个世界,WINDOWS将真个世界分解为一个个的窗口,每个窗口有自己的容貌,下面我们将一一揭开 ...

  5. Java笔记之数组

    1.int flags[] = new int[10];数组中的每个元素初始化为0. Arrays.fill(flags, 0);将数组中每个元素置为0.

  6. LeetCode Reverse Nodes in k-Group 每k个节点为一组,反置链表

    题意:给一个单链表,每k个节点就将这k个节点反置,若节点数不是k的倍数,则后面不够k个的这一小段链表不必反置. 思路:递归法.每次递归就将k个节点反置,将k个之后的链表头递归下去解决.利用原来的函数接 ...

  7. HDU5463 Clarke and minecraft

    解题思路:此题刚开始,觉得好繁琐,好混乱,理清思路后,发现很简单.   具体见代码分析. #include<cstdio> #include<cstring> #include ...

  8. An unexpected exception occurred while creating a change object. see the error log for more details

    今天再给Android项目工程中的包重命名时出现了这个错误(之前重命名的时候就没有出现,郁闷): An unexpected exception occurred while creating a c ...

  9. html:唤起手机qq开始对话 & 自动拨号

    <a href="mqqwpa://im/chat?chat_type=wpa&uin=[qq号]&version=1">XXX</a> 另 ...

  10. nsDATA 转结构体

    很多时候需要将c,c++形式的struct转换为  NSData来处理.但是怎么转换呢? 假设有这么一个结构体: struct   MYINFO { int   a; long  b; char  c ...