#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. lightoj 1008

    水题,开根号判断大致范围,再找即可. #include<cstdio> #include<cmath> #include<cstdlib> using namesp ...

  2. 怎样从官网下载Spring的jar包

    第一种,简单粗暴直接http://repo.springsource.org/libs-release-local/org/springframework/spring/3.2.4.RELEASE/s ...

  3. 【HTML】Beginner4:Heading

    1.Headings h1 h2 h3 h4 h5 h6     h1 being the almighty emperor of headings     h6 being the lowest p ...

  4. IT小说

    最近迷上了IT小说,连着读了好几个连载.伴随着一个项目的一些事,一些矛盾,也能体现出一个社会的缩影.最吸引的应该是一种熟悉感,常常想要是拍成电视剧也应该很好看,像<半泽植树>似的.看完了, ...

  5. Esper系列(五)Order by、Limit、构建事件流、Updating an Insert Stream

    Order by 与SQL语法类似类似,默认为升序排列; 注意: 如果order by的子句中出现了聚合函数,那么该聚合函数必须出现在select的子句中. 出现在select中的expression ...

  6. Already tried 0 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep解决方法

    14/03/26 23:10:04 INFO ipc.Client: Retrying connect to server: 0.0.0.0/0.0.0.0:10020. Already tried ...

  7. 如何在Windows中打开多个Windows Media Player

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:如何在Windows中打开多个Windows Media Player.

  8. Oracle的commit详解(转)

    java通过jdbc thin方式连接数据库后,对数据库操作时会出现以下两种情况,我这可能记录不全: 1.在sqlplus中查询得到和java终端中输出的查询结果不同 2.执行某些sql语句卡住不动 ...

  9. C++中随机函数

    #include <iostream> using namespace std; #include <stdlib.h> #include <time.h> int ...

  10. FZOJ2110 star(DFS)

    Overpower often go to the playground with classmates. They play and chat on the playground. One day, ...