W’s Cipher
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 5811 Accepted: 2903

Description

Weird Wally’s Wireless Widgets, Inc. manufactures an eclectic assortment of small, wireless, network capable devices, ranging from dog collars, to pencils, to fishing bobbers. All these devices have very small memories. Encryption algorithms like Rijndael, the candidate for the Advanced Encryption Standard (AES) are demonstrably secure but they don’t fit in such a tiny memory. In order to provide some security for transmissions to and from the devices, WWWW uses the following algorithm, which you are to implement.

Encrypting a message requires three integer keys, k1, k2, and k3. The letters [a-i] form one group, [j-r] a second group, and everything else ([s-z] and underscore) the third group. Within each group the letters are rotated left by ki positions in the message. Each group is rotated independently of the other two. Decrypting the message means doing a right rotation by ki positions within each group.

Consider the message the_quick_brown_fox encrypted with ki values of 2, 3 and 1. The encrypted string is _icuo_bfnwhoq_kxert. The figure below shows the decrypting right rotations for one character in each of the three character groups.

Looking at all the letters in the group [a-i] we see {i,c,b,f,h,e} appear at positions {2,3,7,8,11,17} within the encrypted message. After a right rotation of k1=2, these positions contain the letters {h,e,i,c,b,f}. The table below shows the intermediate strings that come from doing all the rotations in the first group, then all rotations in the second group, then all the rotations in the third group. Rotating letters in one group will not change any letters in any of the other groups.

All input strings contain only lowercase letters and underscores(_). Each string will be at most 80 characters long. The ki are all positive integers in the range 1-100.

Input

Input consists of information for one or more encrypted messages. Each problem begins with one line containing k1, k2, and k3 followed by a line containing the encrypted message. The end of the input is signalled by a line with all key values of 0.

Output

For each encrypted message, the output is a single line containing the decrypted string.

Sample Input

2 3 1
_icuo_bfnwhoq_kxert
1 1 1
bcalmkyzx
3 7 4
wcb_mxfep_dorul_eov_qtkrhe_ozany_dgtoh_u_eji
2 4 3
cjvdksaltbmu
0 0 0

Sample Output

the_quick_brown_fox
abcklmxyz
the_quick_brown_fox_jumped_over_the_lazy_dog
ajsbktcludmv

Source

Mid-Central USA 2001

Regionals 2001 >> North America - Mid-Central USA

问题链接:POJ1107 ZOJ1042 UVALive2291 W’s Cipher
问题简述:(略)
问题分析
    这个问题是一个密码问题,用模拟法来实现,按照题意模拟即可。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C语言程序如下:

/* POJ1107 ZOJ1042 UVALive2291 W's Cipher */#include <stdio.h>
#include <string.h>#define N 80
char s[N + 1], t1[N + 1], t2[N + 1], t3[N + 1], s1[N + 1], s2[N + 1];void fix(char t[],int k,int len)
{int i, j;k = len - k % len;for(i = 0; i < k; i++)s1[i] = t[i];s1[i]='\0';for(i = k, j = 0; i < len; i++)s2[j++] = t[i];s2[j]='\0';strcat(s2, s1);strcpy(t, s2);
}int main(void)
{int k1, k2, k3, len, i1, i2, i3, i;while(~scanf("%d%d%d", &k1, &k2, &k3) && (k1 || k2 || k3)) {memset(t1, 0, sizeof(t1));memset(t2, 0, sizeof(t2));memset(t3, 0, sizeof(t3));scanf("%s", s);len = strlen(s);i1 = i2 = i3 = 0;for(i = 0; i < len; i++)if(s[i] >= 'a' && s[i] <= 'i')  t1[i1++] = s[i];else if(s[i] >= 'j' && s[i] <= 'r') t2[i2++] = s[i];else if( (s[i] >= 's' && s[i] <= 'z' ) || s[i] == '_') t3[i3++] = s[i];if(i1)fix(t1, k1, i1);if(i2)fix(t2, k2, i2);if(i3)fix(t3, k3, i3);i1 = i2 = i3 = 0;for(i = 0; i < len; i++)if(s[i] >= 'a' && s[i] <= 'i')  s[i] = t1[i1++];else if(s[i] >= 'j' && s[i] <= 'r') s[i] = t2[i2++];else if( (s[i] >= 's' && s[i] <= 'z' ) || s[i] == '_') s[i] = t3[i3++];printf("%s\n", s);}return 0;
}

POJ1107 ZOJ1042 UVALive2291 W's Cipher【密码+模拟】相关推荐

  1. Bailian2819 W的密码【密码+模拟】

    2819:W的密码 总时间限制: 1000ms 内存限制: 65536kB 描述 加密一条信息需要三个整数码, k1, k2 和 k3.字符[a-i] 组成一组, [j-r] 是第二组, 其它所有字符 ...

  2. 【Python】忘记登录密码?遍历数字字母组合密码+模拟提交表单

    准备 忘记了密码?试一试暴力破解吧 打开F12,填写用户名.密码后,点击登录,看到请求头信息.提交的表单信息,例如下图: 也可以看到此次登录请求发送到的 url: 也可以看到此次请求返回的结果: 遍历 ...

  3. selenium使用账号密码模拟登陆淘宝,使用账号密码!

    1,需要相关的库如下 from selenium import webdriver from selenium.webdriver.common.action_chains import Action ...

  4. selenium使用账号密码模拟登陆淘宝,使用账号密码

    1,需要相关的库如下 from selenium import webdriver from selenium.webdriver.common.action_chains import Action ...

  5. w ndows7管理员密码,Windows7默认管理员账户用户名和密码是什么

    很多小伙伴更新了系统,下载了深度技术win7系统,但是却不知道这个Windows7默认管理员账户用户名和密码是什么,其实这个没有密码,Windows7默认账户用户名是:Administrator,密码 ...

  6. W ndows10开机密码设置,windows10密码,小编告诉你win10开机密码怎么设置

    对于用户来说,最重要的莫过于用户的个人的隐私了,可见和不可见的,都是最要紧的,为了更好的保护自己的个人隐私,给电脑设置开机密码是必不可少的一道关卡了,不过这对于一些新手来说,是很比较艰难的操作,下面, ...

  7. 北大考研复试上机——W's Cipher

    题目描述 Weird Wally's Wireless Widgets, Inc. manufactures an eclectic assortmentof small, wireless, net ...

  8. Liunx操作系统的引导过程(系统操作引导过程,模拟MBR,GRUB故障,root密码遗忘解决,优化启动过程 ,运行级别的分类)

    文章目录 Liunx操作系统的引导过程 引导过程 Blos自检 MBR 引导 grub引导菜单(Boot Loader) 内核启动 启动init进程,依据inittab文件设定运行级别 系统初始化进程 ...

  9. 挖藕!模拟sql抓取qq密码

    挖藕!模拟sql查看qq密码 模拟抓取到的qq数据 通过封装实现数据库的连接 1. 创建配置文件(包含驱动,url 密码,用户名) 2. 实现封装工具类(涉及类加载机制复习) 3. 利用封装工具类实现 ...

最新文章

  1. android 下拉刷新 组件,android系统自带下拉刷新控件的实现
  2. 单例模式(winform唯一页面)
  3. 20. A *p=NULL,p 可以调用 A 类里面的函数嘛?
  4. ustc小道消息20220107
  5. 年年岁岁花相似,岁岁年年竟相同
  6. 筛选染色体连续区域的策略
  7. 点击文本框后页面变大
  8. MikroTik RouterOS x86最大内存只能支持2G
  9. 简洁大气好看的个人博客模板HTML源码
  10. Android 爱心万花筒简单实现
  11. en55032最新标准下载_欧盟新EMC标准EN55032将强制实施
  12. 如何在服务器里面新建文件夹,怎么在云服务器新建文件夹
  13. 电脑PC端如何下载B站视频?
  14. SuperSlide插件轮播图展示
  15. Unity Shader - CheckerBoard(棋盘格) 等 Pattern 的测试
  16. 中专计算机专业包括哪些方面,中专计算机有什么专业?
  17. 2007年考研时间安排表
  18. 毕业设计 基于单片机的室内温湿度自动控制系统(源码+硬件+论文)
  19. CSS 实现内阴影的方法
  20. 基于windows 10打造的kali工具集-ICS Windows v2.0

热门文章

  1. 【转载】令人作呕的OpenSSL,转自CSDN博主Bomb250
  2. 浅谈Flutter UI布局
  3. 一、bootstrap table 初体验
  4. Starling实现的硬皮翻书效果
  5. 与Xcode相比Adobe AIR开发iOS的优势和局限
  6. 移动设备响应式网站之CSS媒体查询
  7. java中for 的几种常见用法
  8. TTS Service Extended (进程:com.google.tts)意外停止 恢复被阉割的TTS文字转语音功能
  9. 5.2.3 std::atomic的相关操作
  10. Mysql中导入和导出数据库