题目连接

http://acm.hdu.edu.cn/showproblem.php?pid=5264

pog loves szh I

Description

Pog has lots of strings. And he always mixes two equal-length strings. For example, there are two strings: "abcd" and "efgh". After mixing, a new string "aebfcgdh" is coming.

However, szh thinks it is boring, so he reverses the second string, like changing "efgh" to "hgfe". Then mix them as usual, resulting in "ahbgcfde".

Now, here comes a problem. Pog is given a string after mixing by szh, but he wants to find the original two strings.

Hint : In this question, it needs a linefeed at the end of line at hack time.

Input

The first line has an integer, $T(1 \leq T \leq 100)$, indicating the number of cases.

Then follows T lines. Every lines has a string S, whose length is even and not more than 100, and only consists of lower-case characters('a'~'z').

Output

For each cases, please output two lines, indicating two original strings.

Sample Input

1

aabbca

Sample Output

abc

aba

For example, there are two strings: "abcd" and "efgh". After mixing, a new string "aebfcgdh" is coming.

 1 #include<algorithm>
 2 #include<iostream>
 3 #include<string>
 4 using std::cin;
 5 using std::cout;
 6 using std::endl;
 7 using std::string;
 8 int main() {
 9 #ifdef LOCAL
10     freopen("in.txt", "r", stdin);
11     freopen("out.txt", "w+", stdout);
12 #endif
13     std::ios::sync_with_stdio(false);
14     int t;
15     cin >> t;
16     while (t--) {
17         string s1, s2, buf;
18         cin >> buf;
19         for (int i = 0; buf[i]; i++) {
20             if (i & 1) s2 = buf[i] + s2;
21             else s1 += buf[i];
22         }
23         cout << s1 << endl << s2 << endl;
24     }
25     return 0;
26 }

View Code

转载于:https://www.cnblogs.com/GadyPu/p/4561480.html

hdu 5264 pog loves szh I相关推荐

  1. 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? ...

  2. 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 ...

  3. HDU 5266 pog loves szh III【LCA RMQ】

    B - pog loves szh III 题目:添加链接描述 题意:找出区域l到r的LCA->找l和r的LCA 分析: 链式前向星存树,先用dfs处理结点倍增关系. 然后从循环处理较深结点,直 ...

  4. HDU 5266 pog loves szh III (LAC)

    问题描述 pog在与szh玩游戏,首先pog在纸上画了一棵有根树,这里我们定义1为这棵树的根,然后szh在这棵树中选了若干个点,想让pog帮忙找找这些点的最近公共祖先在哪里,一个点为S的最近公共祖先当 ...

  5. HDU - 5265 pog loves szh II (二分或者贪心)

    这题有两种做法,一种是二分,我很快就想到了(nlogn的复杂度,10^6的n). 第二种就是贪心了,我觉得这个不那么容易想到,好像速度要快一些. 首先,我们找答案的两个数x,y,有两种,一种是x+y& ...

  6. hdu 5266 pog loves szh III

    给一棵树,q次询问,每次询问给连续的一个闭区间,问区间所有数的LCA是多少. 做一个dfs序,其中把dfs序最小的点和最大的点做一次LCA求出的点就是答案. #include <bits/std ...

  7. hdu 5266 pog loves szh III LCA+RMQ

    题意: 给你一棵树,然后询问l~r节点的最近公共祖先(LCA). 思路: 用RMQ维护一段区间的LCA,然后询问时,将两个区间的LCA再求一次LCA即可. code: #pragma comment( ...

  8. HDU 5266 pog loves szh III(在线倍增LCA+ST)

    Description 给出一棵有n个节点的树,定义1为树根,有q次询问,每次询问区间[a,b]中所有节点的LCA Input 第一行为一整数n表示节点数,之后n-1行每行两个整数a和b表示树的一条边 ...

  9. HDU 5265 pog loves szh II(二分)

    题意: 给出n,p,n个数,从中取两个数 a,b , 求出( a + b )% p 的最大值. 解析: 先把每个数%p , 可以发现两个数加起来,要么 < p,要么 ≥ p,然后小于 2p. 那 ...

最新文章

  1. linux配置ssh密码远程登录,配置ssh 无需密码即可登录远程服务器
  2. 大型网站核心架构要素--扩展性
  3. 让服务器iis支持.apk文件下载的设置方法
  4. Android中获取当前位置的使用步骤
  5. 《c语言从入门到精通》看书笔记——第11章 结构体和共用体
  6. spring mvc学习(4):第一个spring mvc项目
  7. 【数据结构与算法】红黑树的Java实现
  8. 神舟笔记本触摸板驱动_关闭笔记本触摸板的四种方法
  9. Java的序列化和反序列化
  10. 大数据分析的方法有哪些
  11. Mac OS系统下,代码自动生成器无法使用解决方法
  12. 约瑟夫环 java_约瑟夫环的java实现
  13. winform TreeView节点中的CheckBox 禁用
  14. 小学生怎样学习英语,ProudKids少儿英语推荐几首适合学英语的三年级英语歌曲
  15. 我的世界rpg服务器无限点卷无限金币地址,我的世界RPG插件无限刷任何物品 | 手游网游页游攻略大全...
  16. 2022Java学习笔记八十八(网络编程:UDP通信,一发一收,多发多收消息接收实现)
  17. 清华差生10年奋斗经历:各种反省各种彻悟
  18. 将中文汉字转换成拼音(全拼)
  19. 92%的奢侈品牌开通微信账号 营销到底该如何做?
  20. 哪款蓝牙耳机音质好?2020国产高性价比高音质蓝牙耳机分享

热门文章

  1. photo,image,picture三个词区别以及cinema、film 和movie的用法与差别
  2. 二叉树层序遍历相关题目
  3. FFN(mlpack)
  4. 猎聘招聘网数据可视化
  5. 小米手机安装 charles 证书 windows10
  6. 计算机操作系统_银行家算法
  7. Workflow常见错误如何解决
  8. 当你对未来迷茫的时候请看看这些
  9. wxpython 之 GDI(一)
  10. C语言数码管是共阴共阳程序,单片机程序怎么把共阴数码管程序改成共阳的