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 ...
随机推荐
- AngularJS中的控制器示例_3
<!doctype html> <html ng-app="myApp"> <head> <script src="C:\\Us ...
- python描述符 descriptor
descriptor 在python中,如果一个新式类定义了__get__, __set__, __delete__方法中的一个或者多个,那么称之为descriptor.descriptor通常用来改 ...
- 下一代云计算模式:Docker正掀起个性化商业革命
作者: 吴宁川 来源: ITValue 发布时间: 2015-09-20 10:41 阅读: 10008 次 推荐: 16 原文链接 [收藏] 文/ITValue 记者吴宁川 从 20 ...
- Fedora 22(15以上版本)开机自启动脚本
前段时间做了一个网站btdog磁力与btdog电视直播.DHT爬虫需要消耗比较多的资源,原来的服务器不够用了,于是自己使用电脑搭了一台服务器,使用Fedora22系统.在Fedora22中自动写了些开 ...
- systemd-journald详解
配置文件详解 [Journal] #Storage=persistent Storage=persistent #Compress=yes #Seal=yes #SplitMode=uid #Sync ...
- 第16讲- UI组件之TextView
第16讲 UI组件之TextView Android系统所有UI类都是建立在View和ViewGroup这两类的基础上的. 所有View的子类称为widget:所有ViewGroup的子类称为Layo ...
- Struts2+Spring+Hibernate 三大框架的合并集成
这次来看看Struts2+Spring+Hibernate三大框架的整合应用,主要是Spring和Hibernate框架的整合,因为前边已经将Strtus2+Spring整合过了基本一样. 首先看一 ...
- python学习之路-1 python简介及安装方法
python简介 一种面向对象.解释型计算机程序设计语言,由Guido van Rossum于1989年发明,第一个公开发行版发行于1991年. 目前最新版本为3.5.1,发布于2015年12月07日 ...
- mysql常用操作命令
本章内容:(引用原文:http://www.cnblogs.com/suoning/p/5769141.html) 查看\创建\使用\删除 数据库 用户管理及授权实战 局域网远程连接法 查看\创建\使 ...
- 【Spark Core】任务运行机制和Task源代码浅析1
引言 上一小节<TaskScheduler源代码与任务提交原理浅析2>介绍了Driver側将Stage进行划分.依据Executor闲置情况分发任务,终于通过DriverActor向exe ...