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. Java关键字static、final

    static  1. static变量     按照是否静态的对类成员变量进行分类可分两种:一种是被static修饰的变量,叫静态变量或类变量:另一种是没有被static修饰的变量,叫实例变量.两者的 ...

  2. CodeIgniter 3之Session类库(3)(转)

    本文主要讲CI2和CI3关于Session类库的区别.我们知道CI2的Session类使用了cookie来传递session数据.使用 cookie保存会话的好处在于可以节省服务器资源,但坏处也是显而 ...

  3. JProfiler 使用说明

    一个全功能的 Java 剖析工具( profiler ),专用于分析 J2SE 和 J2EE 应用程序.它把 CPU .执行绪和内存的剖析组合在一个强大的 应用中. JProfiler 可提供许多 I ...

  4. python练习程序(c100经典例21)

    题目: 猴子吃桃问题:猴子第一天摘下若干个桃子,当即吃了一半,还不瘾,又多吃了一个第二天早上又将剩下的桃子吃掉一半,又多吃了一个.以后每天早上都吃了前一天剩下的一半零一个.到第10天早上想再吃时,见只 ...

  5. Pig实战

    1. pig简介 2. 安装pig 3. 实战pig 4. 深入pig 5. 参考资料及代码下载 <1>. Pig简介  pig是hadoop项目的一个拓展项目, 用以简化hadoop编程 ...

  6. Android RemoteViews 11问11答

    1.什么是RemoteView? 答:其实就是一种特殊的view结构,这种view 能够跨进程传输.并且这种remoteview 还提供了一些方法 可以跨进程更新界面.具体在android里面 一个是 ...

  7. Python 字典(Dictionary) get()方法

    描述 Python 字典(Dictionary) get() 函数返回指定键的值,如果值不在字典中返回默认值. 语法 get()方法语法: dict.get(key, default=None) 参数 ...

  8. OpenLayers调用arcgis server发布的地图服务

    有两种方式可以调用arcgis server发布的地图服务,一种是rest,一种是wms.  地图的投影为900913,arcgis server为10.0版本,地图服务的空间参考为3857.   与 ...

  9. JSTL(fn函数)

    JSTL(fn函数) 首先,我们要在页面的最上方引用: <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/js ...

  10. PHP开发常见问题解决列表

    1. 学习Zend Framework tutorial过程中的问题 (1)执行"zf create project zf-tutorial"出现如下错误: '"php. ...