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

 #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. CC2530定时器3的输入捕获中断

    CC2530定时器3的输入捕获中断 使用的是tim3的通道1的输入捕获P1_7口.//GPIO配置成复用功能,同时设置P1_7为输入.void irCaptureGpioInit(void){ P1S ...

  2. Dijkstra算法C#实现及其布线运用

    大家好,我是小鸭酱,博客地址为:http://www.cnblogs.com/xiaoyajiang 以下是空调布线对Dijkstra算法的运用,采用C#实现. 问题:室内机多台,室外机一台.寻找室内 ...

  3. ListView 实现分组

    1:FragmentHack4.java /** * Created by y on 15-1-2. */ public class FragmentHack4 extends Fragment{ V ...

  4. SGU 294 He's Circles

    题意:一个项链有n个珠子,每个珠子为黑色或白色.问有多少种不同的项链? 注意,n的数量十分大,因此,我们枚举i(1<=i<=n),令L=n/i,求出L的欧拉函数,则这些数和L互质,因此gc ...

  5. 【转】ubuntu 12.04 LTS将关闭最大化最小化移动到右上角

    原文网址:http://www.4byte.cn/learning/114801.html ubuntu 12.04 LTS将关闭最大化最小化移动到右上角   还是按下“ALT +F2”组合键,输入g ...

  6. 2015第16周六学习java建议

    学习Java 建议: 尽量用 google 查找技术资料. 有问题在 stackoverflow 找找,大部分都已经有人回答. 多看官方的技术文档. ibm developerworkers 的文章质 ...

  7. flex渐变色制作圆角橙色按钮

    <?xml version="1.0" encoding="utf-8"?> <s:SparkButtonSkin xmlns:fx=&quo ...

  8. hdu 3232 Crossing Rivers(期望 + 数学推导 + 分类讨论,水题不水)

    Problem Description   You live in a village but work in another village. You decided to follow the s ...

  9. c++之 常量

    const常量 当在类型名前面加上关键字const后,表示它是一个只读的量,不能对其进行修改,因而被称为常量. 下面的例子对常量进行修改: const常量是只读的,可以读取它的值,或者用printf打 ...

  10. qemu-kvm-1.1.0源代码中关于迁移的代码分析

    这篇文档基于qemu-kvm-1.1.0源代码进行分析. 首先,源代码中的hmp-commands.hx文件里有下面内容: { .name = "migrate",/* 在moni ...