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 ...
随机推荐
- C#使用SQLite出错:无法加载 DLL“SQLite.Interop.dll”,找不到指定的模块
在SQLite官方下载了System.Data.SQLite,编写如下测试代码: 复制内容到剪贴板 程序代码 using (SQLiteConnection conn = new SQLiteConn ...
- HDU5647 DZY Loves Connecting 树形DP
(先奉上jcvb大神的官方题解)BC 76 div 1 1002 对于每个结点i,统计出f[i]表示包含i的连通集有多少个,那么容易看出答案就是所有f[i]的和. 要计算f[i]是经典的树形DP问题. ...
- Datatable转换成List实体对象列表 几个实例
一, /// <summary> /// 将Datatable转换为List集合 /// </summary> /// <typeparam name="T&q ...
- Android增量更新
http://blog.csdn.net/tu_bingbing/article/details/8538592 (转)
- 谈谈以下关键字的作用auto static register const volatile extern
(1)auto 这个这个关键字用于声明变量的生存期为自动,即将不在任何类.结构.枚举.联合和函数中定义的变量视为全局变量,而在函数中定义的变量视为局部变量.这个关键字不怎么多写,因为所有的变量默认就是 ...
- [九度OJ]1431.Sort(寻找前m大数并排序)
原题链接:http://ac.jobdu.com/problem.php?pid=1431 题目描述: 给你n个整数,请按从大到小的顺序输出其中前m大的数. 输入: 每组测试数据有两行,第一行有两个数 ...
- ACM编程技巧--代码片段
验证n是否是完全平方数 #include<math.h> double m=sqrt(n); if(floor(m+0.5)==m) printf("%d是完全平方数.\n&qu ...
- Mysql常用操作记录
在linux平台中相关的MySql操作 打开Mysql mysql -uroot -p //-u后边为用户名,-p后边为密码 1:使用SHOW语句找出在服务器上当前存在什么数据库:mysql& ...
- linux select 与 阻塞( blocking ) 及非阻塞 (non blocking)实现io多路复用的示例
除了自己实现之外,还有个c语言写的基于事件的开源网络库:libevent http://www.cnblogs.com/Anker/p/3265058.html 最简单的select示例: #incl ...
- 初次接触Android ActionBar比较烦人的问题[转]
本文转自:http://blog.csdn.net/u010933209/article/details/40112079 问题一:icon不能正常显示 一直都对actionbar又爱又恨,特别是刚接 ...