ACM/ICPC ZOJ1006-Do the Untwist 解题代码
#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 解题代码的更多相关文章
- 2017 ACM/ICPC Asia Regional Qingdao Online解题报告(部分)
HDU 6206 Apple 题意: 给出四个点的坐标(每个点的坐标值小于等于1,000,000,000,000),问最后一个点是否在前三个点组成的三角形的外接圆内,是输出Accept,否输出Reje ...
- 【转】lonekight@xmu·ACM/ICPC 回忆录
转自:http://hi.baidu.com/ordeder/item/2a342a7fe7cb9e336dc37c89 2009年09月06日 星期日 21:55 初识ACM最早听说ACM/ICPC ...
- 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 ...
- 2016 ACM/ICPC亚洲区青岛站现场赛(部分题解)
摘要 本文主要列举并求解了2016 ACM/ICPC亚洲区青岛站现场赛的部分真题,着重介绍了各个题目的解题思路,结合详细的AC代码,意在熟悉青岛赛区的出题策略,以备战2018青岛站现场赛. HDU 5 ...
- ACM/ICPC 之 BFS(离线)+康拓展开(TSH OJ-玩具(Toy))
祝大家新年快乐,相信在新的一年里一定有我们自己的梦! 这是一个简化的魔板问题,只需输出步骤即可. 玩具(Toy) 描述 ZC神最擅长逻辑推理,一日,他给大家讲述起自己儿时的数字玩具. 该玩具酷似魔方, ...
- 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 ...
- 【转】ACM/ICPC生涯总结暨退役宣言—alpc55
转自:http://hi.baidu.com/accplaystation/item/ca4c2ec565fa0b7fced4f811 ACM/ICPC生涯总结暨退役宣言—alpc55 前言 早就该写 ...
- 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 ...
- 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 ...
随机推荐
- [摘]selenium-ide命令
关于,selenium 命令这一部分,为了便于像我一样的菜鸟理解,我采用通过例子讲命令的方式. 菜鸟Selenium 命令通常被称为selenese,有一系列运行测试案例所需的命令构成. ----// ...
- NPOI读取Excel案例
3.4用NPOI操作EXCEL--从Excel中抽取文本 我们知道,搜索引擎最擅长处理的就是文本,而Excel中的内容并不是以文本方式存储的.那么如果想要搜索引擎爬虫能够抓取到Excel中的内容是比较 ...
- Flash Builder4.6破解方案(亲测有效)(转)
转自 http://bbs.9ria.com/thread-139463-1-1.html 当修改Host文件无法破解时,需要修改Flash Builder安装目录下某些文件来达到破解的目的,经网上搜 ...
- image sensor 积分时间
integration time 积分时间 当光源周期与integration time成整数倍时才不会产生flicker integration time即积分时间是以行为单位表示曝光时间(exp ...
- HW5.15
public class Solution { public static void main(String[] args) { System.out.printf("%10s\t%10s\ ...
- 互联网挣钱info
AdSense – Google 广告 http://www.freehao123.com/tag/mianfeiphpkongjian/ [免费资源部落;] ntpdate -u time-b.ti ...
- 安装 Linux 与 Windows 10 双系统,你需要了解的一切
该选Windows 10还是Linux Mint?鱼与熊掌当然可以兼得,但咱们得掌握点小技巧才能顺利搞定. Windows 10绝不是唯一一款值得我们安装在自己计算机之上的免费操作系统.Linux只靠 ...
- 成都Uber优步司机奖励政策(2月21日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- spring事物传播机制 事物隔离级别
Spring事务类型详解: PROPAGATION_REQUIRED--支持当前事务,如果当前没有事务,就新建一个事务.这是最常见的选择. PROPAGATION_SUPPORTS--支持当前事务,如 ...
- robotframework-FQA
发现是一波三折,刚开始信步漫游,就又遇上了沟,整理一下吧: 1.WebDriverException: Message: 'geckodriver' executable needs to be i ...