#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int main()
{
string array[30][2];
string a,b;
int t=0;
while( cin >> a )
{
if ( a == "0" )
{
break;
}
else
{
cin >> b;
}
array[t][0] = a;
array[t][1] = b;
t++;
} for ( int i = 0; i < t; i++ )
{
const char *p = array[i][0].c_str();
int k = atoi(p);
int len = array[i][1].size();
int *ciphercode = new int[len];
for ( int s = 0; s <len; s++ )
{
if ( array[i][1][s] == '.')
{
ciphercode[s] = 27;
}
else if ( array[i][1][s] == '_')
{
ciphercode[s] = 0;
}
else
{
ciphercode[s] = array[i][1][s] - 96;
}
} int *plaincode = new int[len];
for ( int s = 0; s < len; s++ )
{
int pt = ( k*s )%len;
plaincode[pt] = (ciphercode[s] + s)%28; //cout <<pt <<" "<< plaincode[pt] << " ";
}
//cout << endl; char *plaintext = new char[len];
//cout << plaintext << endl;
for ( int s = 0; s < len; s++ )
{
if (plaincode[s] == 0 )
{
plaintext[s] = '_';
}
else if (plaincode[s] == 27 )
{
plaintext[s] = '.';
}
else
{
plaintext[s] = plaincode[s] + 96;
}
}
//string resut(plaintext);
for ( int m = 0; m < len; m++ )
{
cout << plaintext[m];
}
cout << endl;
delete [] plaincode;
delete [] plaintext;
delete [] ciphercode;
}
return 0;
}

  

ACM/ICPC ZOJ1006-Do the Untwist 解题代码的更多相关文章

  1. 2017 ACM/ICPC Asia Regional Qingdao Online解题报告(部分)

    HDU 6206 Apple 题意: 给出四个点的坐标(每个点的坐标值小于等于1,000,000,000,000),问最后一个点是否在前三个点组成的三角形的外接圆内,是输出Accept,否输出Reje ...

  2. 【转】lonekight@xmu·ACM/ICPC 回忆录

    转自:http://hi.baidu.com/ordeder/item/2a342a7fe7cb9e336dc37c89 2009年09月06日 星期日 21:55 初识ACM最早听说ACM/ICPC ...

  3. hduoj 4712 Hamming Distance 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...

  4. 2016 ACM/ICPC亚洲区青岛站现场赛(部分题解)

    摘要 本文主要列举并求解了2016 ACM/ICPC亚洲区青岛站现场赛的部分真题,着重介绍了各个题目的解题思路,结合详细的AC代码,意在熟悉青岛赛区的出题策略,以备战2018青岛站现场赛. HDU 5 ...

  5. ACM/ICPC 之 BFS(离线)+康拓展开(TSH OJ-玩具(Toy))

    祝大家新年快乐,相信在新的一年里一定有我们自己的梦! 这是一个简化的魔板问题,只需输出步骤即可. 玩具(Toy) 描述 ZC神最擅长逻辑推理,一日,他给大家讲述起自己儿时的数字玩具. 该玩具酷似魔方, ...

  6. hduoj 4710 Balls Rearrangement 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4710 Balls Rearrangement Time Limit: 6000/3000 MS (Java/Ot ...

  7. 【转】ACM/ICPC生涯总结暨退役宣言—alpc55

    转自:http://hi.baidu.com/accplaystation/item/ca4c2ec565fa0b7fced4f811 ACM/ICPC生涯总结暨退役宣言—alpc55 前言 早就该写 ...

  8. hduoj 4708 Rotation Lock Puzzle 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4708 Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/O ...

  9. hduoj 4715 Difference Between Primes 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4715 Difference Between Primes Time Limit: 2000/1000 MS (J ...

随机推荐

  1. Read ListViewItem content from another process z

    Normal Windows GUI applications work with messages that are sent to a window or control and the cont ...

  2. C# 日期转换为中文大写

    /// <summary> /// 日期转换为中文大写 /// </summary> public class UpperConvert { public UpperConve ...

  3. 使用curl下载文件

    curl是一个非常好的网络传输库,使用也很简单.常用的使用方式是用它来下载资源文件,以下提供一个下载方法 #include <stdio.h> #include <iostream. ...

  4. 2015年10月22日CSS学习笔记

    XHTML1.0对HTML4.0的改进 借鉴了XML的写法,语法更加严格. 把页面的内容和样式分离了,废弃了html4中的表示样式的标签和属性.推荐使用css来描述页面的样式. CSS样式的优先级 ! ...

  5. 【Java基础】Java中的持久属性集Properties

    Properties 类的介绍 Properties 类表示了一个持久的属性集.Properties 可保存在流中或从流中加载.属性列表中每个键及其对应值都是一个字符串.一个属性列表可包含另一个属性列 ...

  6. POJ1840: Eqs(hash问题)

    一道典型的hash问题: 已知a1,a2,a3,a4,a5,求有多少种不同的<x1,x2,x3,x4,x5>组合满足等式: a1*x1^3 + a2*x2^3 + a3*x3^3 + a4 ...

  7. Android: Dragging Popup Window 可移动浮动View

    final View cv = new View(this); setContentView(cv); TextView tv = new TextView(this); tv.setBackgrou ...

  8. 无法通过 128 (在表空间 TEMP 中) 扩展 temp 段

    1.查看表空间中数据文件存储的路径以及是否可以自动扩展 SELECT TABLESPACE_NAME, BYTES/1024/1024 FILE_SIZE_MB, FILE_NAME FROM DBA ...

  9. jquery 模块拖拽

    这是模块拖拽Javascript代码 $(function(){ var _move=false;//移动标记 var _x,_y;//鼠标离控件左上角的相对位置 $(".drag" ...

  10. Android中解析JSON格式数据常见方法合集

    待解析的JSON格式的文件如下: [{"id":"5", "version":"1.0", "name&quo ...