1006 Do the Untwist
考察编程基础知识,用到字符和数字相互转化等。形式是描述清楚明文和暗文的转化规则。
#include <stdio.h>
#include <string.h>
#define MAXLEN 71
int length;
void toCode(int code[],char text[]){
int i;
;i<length;i++){
if(text[i] == '_')
code[i] = ;
else if(text[i] == '.')
code[i] = ;
else
code[i] = text[i] - ;
}
}
void toText(char text[],int code[]){
int i;
;i<length;i++){
)
text[i] = '_';
)
text[i] = '.';
else
text[i] = code[i] + ;
}
text[i] = ;
}
int inRange(int n){
&&n<=)
;
;
}
void untwist(char textC[],int k){
int i,j;
int codeC[MAXLEN],codeP[MAXLEN];
char textP[MAXLEN];
toCode(codeC,textC);
;i<length;i++){
j = (k*i)%length;
if(inRange(codeC[i] + i))
codeP[j] = codeC[i] + i;
))
codeP[j] = codeC[i] + i - ;
))
codeP[j] = codeC[i] + i - ;
))
codeP[j] = codeC[i] + i - ;
}
toText(textP,codeP);
printf("%s\n",textP);
}
int main(){
int k;
char textC[MAXLEN];
while(scanf("%d",&k)&&k){
scanf("%s",textC);
length = strlen(textC);
untwist(textC,k);
}
;
}
1006 Do the Untwist的更多相关文章
- 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 题目大意:给你加密方式,请你求出解密. 直接逆运算搞,用到同余定理 ...
- Do the Untwist(模拟)
ZOJ Problem Set - 1006 Do the Untwist Time Limit: 2 Seconds Memory Limit: 65536 KB Cryptography ...
- POJ题目细究
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP: 1011 NTA 简单题 1013 Great Equipment 简单题 102 ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- ZOJ 1006:Do the Untwist(模拟)
Do the Untwist Time Limit: 2 Seconds Memory Limit: 65536 KB Cryptography deals with methods of ...
- SCNU 2015ACM新生赛初赛【1006. 3D打印】解题报告
题目链接详见SCNU 2015新生网络赛 1006. 3D打印 .出题思路来自codevs 3288. 积木大赛,属于模拟题. 首先我们把“选择从第L部分到第R部分”理 ...
- PKU 1006
数学问题吧,有兴趣的可以研究一下“中国剩余定理” // 1006.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include < ...
- 【BZOJ】1006: [HNOI2008]神奇的国度
http://www.lydsy.com/JudgeOnline/problem.php?id=1006 题意:在一个弦图中找最少染色数.(n<=10000, m<=1000000) #i ...
随机推荐
- jquery实现当前页面编辑
实现效果 代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ww ...
- nginx的url重写[rewrite规则和参考]
本日志内容来自互联网和平日使用经验,整理一下方便日后参考. Nginx Rewrite 相关指令有 if.rewrite.set.return 等. if 的语法 应用于 server 和 locat ...
- 【破解】破解ACDSEE15的方法
1.先从官方下载一个ACDSEE15简体中文版 2.下载注册机(点我下载) 3.修改注册表 修改注册表ACDSee 32位:HKEY_LOCAL_MACHINE\SOFTWARE\ACD System ...
- Android 之Activity切换动画效果
在Activity中Android提供了overridePendingTransition(int enterAnim,int exitAnim)这个方法用于设置Activity之间切换的动画效果.o ...
- cygwin--简单备忘
cygwin是windows上使用linux的一个东东 linux中可以apt-get来安装软件,在cygwin中则使用apt-cyg来安装软件 具体怎么玩的呢: 1.下载cygwin 2.下载并且修 ...
- 数据结构之单链表,c#实现
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- UESTC_Dividing Numbers CDOJ 1156
Dividing Numbers Time Limit: 9000/3000MS (Java/Others) Memory Limit: 262144/262144KB (Java/Other ...
- Best Meeting Point 解答
Question A group of two or more people wants to meet and minimize the total travel distance. You are ...
- POJ3261-哈希
这个题让求至少出现K次的最大长度的子串,属于最大化最小值问题,首先应该想到二分求字串的长度,二分的过程是O(logN)的,注意judge的时候怎样判断是否满足情况以及满足情况后l,r的变化.可以给每一 ...
- nodejs学习笔记之网络编程
了解一下OSI七层模型 OSI层 功能 TCP/IP协议 应用层 文件传输,电子邮件,文件服务,虚拟终端 TFTP,HTTP,SNMP,FTP,SMTP,DNS,Telnet 表示层 数据格式化 ...