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: 为什么要使用"抽象类"? 使用"抽象类"有什么好处?

    老是在想为什么要引用抽象类,一般类不就够用了吗.一般类里定义的方法,子类也可以覆盖,没必要定义成抽象的啊. 看了下面的文章,明白了一点. 其实不是说抽象类有什么用,一般类确实也能满足应用,但是现实中确 ...

  2. Android程序架构基本内容概述

    在Android操作系统中开发的应用程序都有一个结构缜密的架构.我们今天就来对这一Android程序架构做一个详细的分析.帮助大家了解程序开发的特点,以方便将来在应用程序开中明确自己的程序架构. An ...

  3. Linux kernel scriptes bin2c "\x"

    /**************************************************************************** * Linux kernel scripte ...

  4. php 计算本月第一天 本月最后一天 下个月第一天

    本文转载自   http://jin541223.blog.163.com/blog/static/1637398052011111233018533/ //本周第一天(星期日为一周开始) echo ...

  5. 大数据时代的技术hive:hive介绍

    我最近研究了hive的相关技术,有点心得,这里和大家分享下. 首先我们要知道hive到底是做什么的.下面这几段文字很好的描述了hive的特性: 1.hive是基于Hadoop的一个数据仓库工具,可以将 ...

  6. 【转】Github轻松上手5-站在巨人的肩膀上(Fork)

    转自:http://blog.sina.com.cn/s/blog_4b55f6860100zzj3.html 有时候你可能想给别人的项目出把力,或者想以别人的项目作为自己项目的起点,在Github里 ...

  7. python基础之使用os.system来执行系统命令

    今天我们来尝试使用python 的os.system来执行系统命令 可以使用如下方法: import osprint os.system('ping www.baidu.com') 输出的结果是:64 ...

  8. Android adb shell命令大全

    1. 显示系统中全部Android平台: android list targets 2. 显示系统中全部AVD(模拟器): android list avd 3. 创建AVD(模拟器): androi ...

  9. ulimit 命令

    用途:ulimit用于shell启动进程所占用的资源. 类别:shell内建命令 语法格式:ulimit [-acdfHlmnpsStvw] [size] 参数: -H 设置硬资源限制. -S 设置软 ...

  10. 嵌入式 H264中的SPS、PPS提取与作用

    使用RTP传输H264的时候,需要用到sdp协议描述,其中有两项:Sequence Parameter Sets (SPS) 和Picture Parameter Set (PPS)需要用到,那么这两 ...