zoukankan      html  css  js  c++  java
  • hdu 5264 pog loves szh I

    题目连接

    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

     

    By: GadyPu 博客地址:http://www.cnblogs.com/GadyPu/ 转载请说明
  • 相关阅读:
    http 请求头设置缓存
    手把手教你开发chrome扩展一:开发Chrome Extenstion其实很简单
    django如何用邮箱代替用户名登录
    python函数式编程学习之map,reduce,filter,sorted
    python traceback学习(转)
    python logging模块学习(转)
    python pip安装lxml失败(转)
    python下性能提示
    python移植性提示
    python测试与调试提示
  • 原文地址:https://www.cnblogs.com/GadyPu/p/4561480.html
Copyright © 2011-2022 走看看