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 ...
随机推荐
- wordpress博客搬家心得
更改SSH的连接端口和登录账户 在SSH的配置文件,/etc/ssh/sshd_config中找到Port 22(一般情况下是22, 根据服务器提供商的设置而不同)更改为你自己希望的端口. 至于登录账 ...
- 【经验】在CSS中定义a:link、a:visited、a:hover、a:active顺序
摘自:http://www.qianyunlai.com/post-2.html 以前用CSS一直没有遇到过这个问题,在最近给一个本科同学做的项目里面.出现一些问题,搜索引擎查了一些网站和资料 ...
- hdu 1116 Play on Words
http://acm.hdu.edu.cn/showproblem.php?pid=1116 欧拉通路和欧拉回路 #include <cstdio> #include <cstrin ...
- Codeforces 509F Progress Monitoring
http://codeforces.com/problemset/problem/509/F 题目大意:给出一个遍历树的程序的输出的遍历顺序b序列,问可能的树的形态有多少种. 思路:记忆化搜索 其中我 ...
- PowerShell中的输出
1 输出重定向 > 或者>> 2 输出控制 out-* -paging#分页输出 get-process | out-host -paging more指令用于屏显 get-pro ...
- cmake编译Debug和Release
CMake 中有一个变量 CMAKE_BUILD_TYPE ,可以的取值是 Debug Release Rel WithDebInfo 和 MinSizeRel.当这个变量值为 Debug 的时候,C ...
- 运行jar应用程序引用其他jar包的四种方法(转)
Runnable JAR RunnableJAR(1)在Eclipse中操作 上面的截图中eclipse的版本是: 方案二:安装Eclipse打包插件Fat Jar 方案一对于含有较多第三方jar文 ...
- uva10245-The Closest Pair Problem(平面上的点分治)
解析:平面上的点分治,先递归得到左右子区间的最小值d,再处理改区间,肯定不会考虑哪些距离已经大于d的点对,对y坐标归并排序,然后从小到大开始枚举更新d,对于某个点,x轴方向只用考虑[x-d,x+d]( ...
- <% %> 、 <%= %> 、<%# %> 的区别
1,<% %>用来绑定后台代码 中间一般放函数或者方法,典型的asp程序写法. 在前台页面可以写后台代码 相当于开辟了C#空间,可以写C#代码 2,& ...
- time date 基础操作
一. 获取当前系统时间和日期并格式化输出: import java.util.Date;import java.text.SimpleDateFormat; public class NowStrin ...