考察编程基础知识,用到字符和数字相互转化等。形式是描述清楚明文和暗文的转化规则。

 #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的更多相关文章

  1. ZOJ Problem Set - 1006 Do the Untwist

    今天在ZOJ上做了道很简单的题目是关于加密解密问题的,此题的关键点就在于求余的逆运算: 比如假设都是正整数 A=(B-C)%D 则 B - C = D*n + A 其中 A < D 移项 B = ...

  2. [ZOJ 1006] Do the Untwist (模拟实现解密)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=6 题目大意:给你加密方式,请你求出解密. 直接逆运算搞,用到同余定理 ...

  3. Do the Untwist(模拟)

    ZOJ Problem Set - 1006 Do the Untwist Time Limit: 2 Seconds      Memory Limit: 65536 KB Cryptography ...

  4. POJ题目细究

    acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  102 ...

  5. 【转】POJ百道水题列表

    以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...

  6. ZOJ 1006:Do the Untwist(模拟)

    Do the Untwist Time Limit: 2 Seconds      Memory Limit: 65536 KB Cryptography deals with methods of ...

  7. SCNU 2015ACM新生赛初赛【1006. 3D打印】解题报告

            题目链接详见SCNU 2015新生网络赛 1006. 3D打印 .出题思路来自codevs 3288. 积木大赛,属于模拟题.         首先我们把“选择从第L部分到第R部分”理 ...

  8. PKU 1006

    数学问题吧,有兴趣的可以研究一下“中国剩余定理” // 1006.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include < ...

  9. 【BZOJ】1006: [HNOI2008]神奇的国度

    http://www.lydsy.com/JudgeOnline/problem.php?id=1006 题意:在一个弦图中找最少染色数.(n<=10000, m<=1000000) #i ...

随机推荐

  1. mysql在关闭时的几个阶段

    mysql关闭的大致过程 1.The shutdown process is initiated 初始化关机过程有许多种方法1.mysqladmin shutdown ; 2.kill pid_of_ ...

  2. smarty模板执行原理

    为了实现程序的业务逻辑和内容表现页面的分离从而提高开发速度,php 引入了模板引擎的概念,php 模板引擎里面最流行的可以说是smarty了,smarty因其功能强大而且速度快而被广大php web开 ...

  3. bzoj1060 [ZJOI2007]时态同步

    Description 小Q在电子工艺实习课上学习焊接电路板.一块电路板由若干个元件组成,我们不妨称之为节点,并将其用数字1,2,3….进行标号.电路板的各个节点由若干不相交的导线相连接,且对于电路板 ...

  4. Tomcat启动load action异常

    近期将之前的项目移到另一个文件夹中(包的路径也更改了),启动Tomcat之后包错:无法加载action,看错误提示知道是路径错误,网上也有各种各样的解决方案,这里我的错误是因为项目移到了别的文件中,所 ...

  5. Majority Element 解答

    Solution 1 Naive way First, sort the array using Arrays.sort in Java. Than, scan once to find the ma ...

  6. c++中经常需要访问对象中的成员的三种方式

    可以有3种方法: 通过对象名和成员运算符访问对象中的成员; 通过指向对象的指针访问对象中的成员; 通过对象的引用变量访问对象中的成员. 一.通过对象名和成员运算符访问对象中的成员 例如在程序中可以写出 ...

  7. 表单javascript checkbox全选 反选 全不选

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...

  8. redis 的基本语法

    Redis::__construct构造函数 $redis = new Redis(); connect, open 链接redis服务 参数 host: string,服务地址 port: int, ...

  9. jquery.validate详解二

    五.常用方法及注意问题 1.用其他方式替代默认的SUBMIT $().ready(function() {  $("#signupForm").validate({         ...

  10. Android设备的ID

    Android的开发者在一些特定情况下都需要知道手机中的唯一设备ID.例如,跟踪应用程序的安装,生成用于复制保护的DRM时需要使用设备的唯一ID.在本文档结尾处提供了作为参考的示例代码片段. 范围 本 ...