HDU 5264 pog loves szh I (字符串,水)
题意:设有两个串A和B,现将B反转,再用插入的形式合成一个串。如:A:abc B:efg;反转B先,变gfe;作插入,agbfce。现在给出一个串,要求还原出A和B。
思路:扫一遍O(n),串A在扫的时候直接输出,串2在扫的时候反向存储,再输出。
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;
const int N=;
char str[N];
char s2[N]; void cal(int len)
{
int j=;
for(int i=,p=len-; i<len; i+=)
{
printf("%c",str[i]);
s2[j++]=str[p];
p-=;
}
s2[j]='\0';
printf("\n%s\n",s2);
} int main()
{
//freopen("input.txt", "r", stdin);
int t;
cin>>t;
while(t--)
{
scanf("%s",str);
cal(strlen(str));
} return ;
}
AC代码
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 水题
pog loves szh I Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?p ...
- 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 5265 pog loves szh II (二分查找)
[题目链接]click here~~ [题目大意]在给定 的数组里选两个数取模p的情况下和最大 [解题思路]: 思路见官方题解吧~~ 弱弱献上代码: Problem : 5265 ( pog love ...
- 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 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 ...
随机推荐
- POJ 2151 Check the difficulty of problems (概率dp)
题意:给出m.t.n,接着给出t行m列,表示第i个队伍解决第j题的概率. 现在让你求:每个队伍都至少解出1题,且解出题目最多的队伍至少要解出n道题的概率是多少? 思路:求补集. 即所有队伍都解出题目的 ...
- Gdata XML解析配置和简单使用
导入libxml2,使用第三方AFNetworking网络请求,第三方XML解析GData GData需要的配置 Build Settings 里搜索,添加如下
- iOS文件操作
]; NSString *plistPath = [filePath stringByAppendingPathComponent:@"collect ...
- POJ 2109
#include<iostream> #include<stdio.h> #include<math.h> using namespace std; int mai ...
- DB2 DATE类型在显示的时候,带有00:00:00,去掉的方法,使用VARCHAR()函数
DROP VIEW DMS.V_AQ_INSURANCECLAIMS; CREATE VIEW DMS.V_AQ_INSURANCECLAIMS AS SELECT * FROM (SELECT T1 ...
- 初始BOM
1.BOM(Browser Object Model),定义了操作浏览器的借口 2.常用的BOM对象:Window, History,Navigator,Screen, Location等 3.由于浏 ...
- Project Euler 101 :Optimum polynomial 最优多项式
Optimum polynomial If we are presented with the first k terms of a sequence it is impossible to say ...
- NIM博弈的必胜取法
#include<stdio.h> ; int a[Max]; int main() { int i,n,ans; int tmp; while(scanf("%d", ...
- 编写基于outlook显示的html邮件需要注意的问题
outlook对于html的支持是有限制的,在编写这些html的时候注意遵循以下规则: Never use colspans or rowspans. Always set correct dimen ...
- AOJ - 0009 Prime Number (素数筛法) && AOJ - 0005 (求最大公约数和最小公倍数)
http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=34870 求n内的素数个数. /* ********************* ...