Do the Untwist
Do the Untwist
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 982 Accepted Submission(s): 638
Problem Description
| Array | 0 | 1 | 2 |
| plaintext | 'c' | 'a' | 't' |
| plaincode | 3 | 1 | 20 |
| ciphercode | 3 | 19 | 27 |
| ciphertext | 'c' | 's' | '.' |
Sample Input
5 cs.
101 thqqxw.lui.qswer
3 b_ylxmhzjsys.virpbkr
0
Sample Output
cat
this_is_a_secret
beware._dogs_barking 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1129 题目意思很简单,倒推明文;题目给出的例子是:【cat --> cs.】
第一步:把cat转化成对应数字 plaincode,文中有提到,_=0, .=27, a=1 ...【cat --> 3,1,20】
第二步:利用公式将 plaincode转化成密文对应的数字 ciphercode【3,1,20 --> 3,19,27】
第三步:将 ciphercode转化成密文 【3,19,27 --> cs.】
题目给出密匙k和密文,要求求出明文; 此题最关键的是公式的转化!
公式如下:
明文-->密文:ciphercode[i] = (plaincode[ki mod n] - i) mod 28.
密文-->明文:plaincode[ki mod n] = (ciphercode[i] + i) mod 28.![]()
#include<stdio.h>
#include<string.h>
int main()
{
char s[],b[];
int i,j,n,k;
while(scanf("%d",&k),k)
{
scanf("%s",s);
n=strlen(s);
for(i=;i<n;i++)
{
if(s[i]=='_')
s[i]=;
else if(s[i]=='.')
s[i]=;
else
s[i]=s[i]-'a'+;
}
for(i=;i<n;i++)
{
b[k*i%n]=(s[i]+i)%;
}
for(i=;i<n;i++)
{
if(b[i]==)
printf(".");
else if(b[i]==)
printf("_");
else
printf("%c",b[i]+'a'-);
}
printf("\n");
}
return ;
}
Do the Untwist的更多相关文章
- 1006 Do the Untwist
考察编程基础知识,用到字符和数字相互转化等.形式是描述清楚明文和暗文的转化规则. #include <stdio.h> #include <string.h> #define ...
- ZOJ 1006:Do the Untwist(模拟)
Do the Untwist Time Limit: 2 Seconds Memory Limit: 65536 KB Cryptography deals with methods of ...
- Do the Untwist(模拟)
ZOJ Problem Set - 1006 Do the Untwist Time Limit: 2 Seconds Memory Limit: 65536 KB Cryptography ...
- ZOJ Problem Set - 1006 Do the Untwist
今天在ZOJ上做了道很简单的题目是关于加密解密问题的,此题的关键点就在于求余的逆运算: 比如假设都是正整数 A=(B-C)%D 则 B - C = D*n + A 其中 A < D 移项 B = ...
- [ZOJ 1006] Do the Untwist (模拟实现解密)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=6 题目大意:给你加密方式,请你求出解密. 直接逆运算搞,用到同余定理 ...
- ACM/ICPC ZOJ1006-Do the Untwist 解题代码
#include <iostream> #include <string> #include <stdlib.h> using namespace std; int ...
- ZOJ1006 Do the Untwist
简单模拟~ #include<bits/stdc++.h> using namespace std; ; int a[maxn]; unordered_map<char,int> ...
- 杭电ACM分类
杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...
- POJ题目细究
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP: 1011 NTA 简单题 1013 Great Equipment 简单题 102 ...
随机推荐
- bzoj1041 圆上的整点 数学
题目传送门 题目大意:求一个给定的圆(x^2+y^2=r^2),在圆周上有多少个点的坐标是整数. 思路:没思路,看大佬的博客(转载自https://blog.csdn.net/csyzcyj),转载只 ...
- 加、减、乘、除 高精度 string
#include<stdio.h> #include<string> #include<string.h> #include<iostream> usi ...
- docker 解决容器时间与主机时间不一致的问题
环境: 1.阿里云ecs服务器 2.docker 3.docker镜像 centos7.4.1708 方法一: 查看主机时间: [root@iZbp1625jeg61bc2zzfcotZ docker ...
- 转 LIST INCARNATION OF DATABASE
incarnation在英文中是“化身”的意思. 那么在oracle中,它又是什么意思呢?有什么作用呢? 我们看一些基本概念 Current Incarnation(当前化身):数据库当前正在使用的化 ...
- mysql 配置文件详解
mysql配置文件参数详解 (一) [client]port = 3306socket = /tmp/mysql.sock [mysqld]port = 3306socket = /tmp/mysql ...
- shell 括号的区别
$() 用于命令交换 里面会会执行命令,如果你写其他的: 会直接报错的 ` ` 也是用于命令交换的哦 和$() 的操作是一样的 ${ } 用于变量替换 每次调用环境的时候是需要带一个${ } 但是 ...
- RabbitMQ基础知识篇
1.Linux安装RabbitMQ. 参考网址:RPM安装RabbitMQ 仔细阅读. 先安装erlang: su -c 'rpm -Uvh http://mirrors.neusoft.edu. ...
- Linux软件安装的补充
1 使用yum 命令查看软件提供的版本 yum list mysql* 然后比如说都需要安装我们就可以执行命令: yum install mysql* 然后就会安装所有的.会显示所有需要安装的包,和需 ...
- js判断文件是否存在的方法
在做电力监控项目的时候,有一个需求就是左右布局的框架,点击左边的图形文件地址,然后去文件夹中找到文件,再在右边出现对应的图形文件,但是有些文件可能是配置的时候有问题,找不到文件,所以js需要判断,以下 ...
- Django自定义登陆验证后台
支持邮箱/手机号/昵称登录,在django1.6.2测试成功.1.models # -*- encoding: utf-8 -*- from django.db import models from ...