hdu 5264 pog loves szh I 水题
pog loves szh I
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=5264
Description
szh觉得这并不好玩,因此它将第二个字符串翻转了一遍,如efgh变成了hgfe,然后再将这两个字符串交错拼在一起,因此abcd与efgh就成了ahbgcfde啦!
现在问题来了,pog手里有一个由szh亲手拼好的字符串,它想还原出原来的两个字符串,出于szh对pog的爱,szh帮助pog还原出了原来的两个字符串。
Input
接下来T行每行读入一个长度为偶数且仅包含英文小写字母的字符串(|S|≤100)。
Output
对于每组数组,输出两行,表示原来的两个字符串。
Sample Input
1
aabbca
Sample Output
abc
aba
HINT
题意
题解:
读入一个串,第一个字符串首先将指针指向0,然后每次将指针+2输出即可。第二个字符串首先将指针指向n−1,然后每次将指针−2,输出即可。
注意题目中描述的是第二个字符串经过翻转才得到读入的字符串的。
代码:
//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 2000001
#define mod 10007
#define eps 1e-9
int Num;
char CH[];
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
inline void P(int x)
{
Num=;if(!x){putchar('');puts("");return;}
while(x>)CH[++Num]=x%,x/=;
while(Num)putchar(CH[Num--]+);
puts("");
}
//************************************************************************************** int main()
{
//test;
int t=read();
while(t--){
string s,s1,s2;
cin>>s;
for(int i=;i<s.size();i+=)
s1+=s[i];
for(int i=s.size()-;i>=;i-=)
s2+=s[i];
cout<<s1<<endl;
cout<<s2<<endl;
}
}
hdu 5264 pog loves szh I 水题的更多相关文章
- hdu 5264 pog loves szh I
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5264 pog loves szh I Description Pog has lots of stri ...
- HDU 5264 pog loves szh I (字符串,水)
题意:设有两个串A和B,现将B反转,再用插入的形式合成一个串.如:A:abc B:efg:反转B先,变gfe:作插入,agbfce.现在给出一个串,要求还原出A和B. 思路:扫一遍O(n),串A在 ...
- hdu 5266 pog loves szh III(lca + 线段树)
I - pog loves szh III Time Limit:6000MS Memory Limit:131072KB 64bit IO Format:%I64d & %I ...
- hdu 5265 pog loves szh II
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5265 pog loves szh II Description Pog and Szh are pla ...
- hdu 5265 pog loves szh II STL
pog loves szh II Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...
- HDU 5266 pog loves szh III(区间LCA)
题目链接 pog loves szh III 题意就是 求一个区间所有点的$LCA$. 我们把$1$到$n$的$DFS$序全部求出来……然后设$i$的$DFS$序为$c[i]$,$pc[i]$为$c ...
- HDU 5266 pog loves szh III ( LCA + SegTree||RMQ )
pog loves szh III Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Oth ...
- HDU 5265 pog loves szh II (二分查找)
[题目链接]click here~~ [题目大意]在给定 的数组里选两个数取模p的情况下和最大 [解题思路]: 思路见官方题解吧~~ 弱弱献上代码: Problem : 5265 ( pog love ...
- HDU 5266 pog loves szh III 线段树,lca
Pog and Szh are playing games. Firstly Pog draw a tree on the paper. Here we define 1 as the root of ...
随机推荐
- Delphi 注册文件类型 设置文件图标
{------------------------------------------------------------------------------- @过程名: slpert -& ...
- Monitor traffic to localhost from IE or .NET
原文:http://docs.telerik.com/fiddler/Configure-Fiddler/Tasks/MonitorLocalTraffic Monitor traffic to lo ...
- C语言的 (强制类型转换) 以及 '字符字面值'
C语言的显式/隐式类型转换,都有一个中间变量的存在,原数据的类型.内容都不变. 以下代码,都用GCC编译. #include<stdio.h> int main() { char c = ...
- pycharm出现乱码
1. 'gbk' codec can't encode character u'\xb8' 解决办法 import sys reload(sys)sys.setdefaultencoding('utf ...
- storm流式大数据处理流行吗
在如今这个信息高速增长的今天,信息实时计算处理能力已经是一项专业技能了,正是因为有了这些需求的存在才使得分布式,同时具备高容错的实时计算系统Storm才变得如此受欢迎,为什么这么说呢?下面看看新霸哥的 ...
- JavaScript高级程序设计(第三版)第五章 引用类型
5.2 Array类型 var colors = new Array(3); //创建一个包含3项的数组 var names = new Array("Greg"); //创建一个 ...
- 性能测试-Jmeter
缘由 很多情况下我们写程序过程中只会对固定模块采取并发限制,而且asp.net对于多线程也有他自己的处理机制,尤其对于注重业务,结果导向的团队可能更注重一定时间节点给出满意的产品,但是你的模块到底是否 ...
- Numpy中的矩阵合并
列合并/扩展:np.column_stack() 行合并/扩展:np.row_stack() >>> import numpy as np >>> a = np.a ...
- NServiceBus-性能测试
NServiceBus: 有效地处理一个消息 处理大量并发 尺度大小不同的服务器 尺度低规格的设备 的最终平衡速度和安全. 基准 许多参数会影响测量性能.最明显的是硬件服务器和CPU核的数量,大小的内 ...
- 用shell求两个文件的差集
假设有两个文件a.file和b.file,分别代表集合A和集合B. a.file的内容如下: abcde b.file的内容如下: cdefg 可以用grep命令 grep命令是常用来搜索文本内容的, ...