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 ...
随机推荐
- HDU3487 Play With Chains(Splay)
很裸的Splay,抄一下CLJ的模板当作复习,debug了一个下午,收获是终于搞懂了以前看这个模板里不懂的内容.以前用这个模板的时候没有看懂为什么get函数返回的前缀要加个引用,经过一下午的debug ...
- HDU 1715 大菲波数(JAVA, 简单题,大数)
题目 //BigInteger 和 BigDecimal 是在java.math包中已有的类,前者表示整数,后者表示浮点数 import java.io.*; import java.util.*; ...
- JavaScript文件应该放在网页的什么位置
JavaScript文件应该放在网页的什么位置 http://www.lihuai.net/qianduan/js/352.html 在<良好的JavaScript编程习惯>系列教程的第三 ...
- POJ 1468
#include <iostream> #define MAXN 5005 using namespace std; struct node { int b_x; int b_y; int ...
- Action Bar详解
Action bar是一个标识应用程序和用户位置的窗口功能,并且给用户提供操作和导航模式.在大多数的情况下,当你需要突出展现用户行为或全局导航的activity中使用action bar,因为acti ...
- Android中如何查看内存(上)
文章参照自:http://stackoverflow.com/questions/2298208/how-to-discover-memory-usage-of-my-application-in-a ...
- SqlServer 常用
Sql的函数 newId() 获得guid: getDatatime() 获得当前时间: Row_number() 分页常用的函数. 比top 好用的函数select Row_Number() ov ...
- [转载]Jmeter那点事·ForEach和If控制器
如果我们要实现一个循环,如果城市是北京,则返回首都:否则,返回城市. 一.新建用户自定义变量 添加-配置元件-用户自定义变量, 定义变量注意命名格式:变量名 加 下划线 加 数字(从1开始计数) ...
- 两个奇葩的C/C++问题
今天为大家介绍几个奇葩的C/C++问题. 1 大家看看下面的输出结果是什么呢? #include <stdio.h> #include <stdlib.h> void ma ...
- iOS在线音乐播放SZKAVPlayer(基于AVPlayer的封装)
由于最近闲着没事,想找有关在线音乐播放的demo学习一下,在gitHub跟code4APP上面查找了很多帖子,结果很多在线音乐都是基于AudioStream实现的,我感觉用起来不太方便.后来突然发现, ...