hdu 4550 卡片游戏
http://acm.hdu.edu.cn/showproblem.php?pid=4550
贪心
#include <cstdio>
#include <cstring>
#include <queue>
#include <string>
#include <iostream>
#include <algorithm>
#define maxn 200
using namespace std; char str[],s2[];
int t;
string s1; int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%s",str);
s1=str[];
int j=;
char ch='';
for(int i=; i<(int)strlen(str); i++)
{
if(str[i]!=''&&str[i]<=ch)
{
j=i;
ch=str[i];
}
}
for(int i=; i<(int)strlen(str); i++)
{
if(i==j) s1=str[i]+s1;
else if(i>j)
{
s1+=str[i];
}
else if(i<j)
{
if(str[i]<=s1[])
{
s1=str[i]+s1;
}
else
{
s1+=str[i];
}
}
}
cout<<s1<<endl;
}
return ;
}
hdu 4550 卡片游戏的更多相关文章
- hdu 4550 卡片游戏 贪心
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4550 题意:有n(n <= 100)个0~9之间的卡片,从左往右将卡片放到之前的卡片最左边或者最 ...
- 卡片游戏(hdu4550)贪心
卡片游戏 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Total Submi ...
- 【sicily】卡片游戏
卡片游戏 Time Limit: 1sec Memory Limit:32MB Description 桌上有一叠牌,从第一张牌(即位于顶面的牌)开始从上往下依次编号为1~n.当至少还剩两张牌 ...
- Sicily 1931. 卡片游戏
题目地址:1931. 卡片游戏 思路: 纯属数据结构中队列的应用,可以练练手. 具体代码如下: #include <iostream> #include <queue> usi ...
- nyoj905 卡片游戏
卡片游戏 时间限制:1000 ms | 内存限制:65535 KB 难度:1 描述 小明最近宅在家里无聊,于是他发明了一种有趣的游戏,游戏道具是N张叠在一起的卡片,每张卡片上都有一个数字,数字 ...
- NYOJ 905 卡片游戏
卡片游戏 时间限制:1000 ms | 内存限制:65535 KB 难度:1 描写叙述 小明近期宅在家里无聊.于是他发明了一种有趣的游戏.游戏道具是N张叠在一起的卡片,每张卡片上都有一个数字,数字 ...
- Java实现 LeetCode 822 翻转卡片游戏(暴力)
822. 翻转卡片游戏 在桌子上有 N 张卡片,每张卡片的正面和背面都写着一个正数(正面与背面上的数有可能不一样). 我们可以先翻转任意张卡片,然后选择其中一张卡片. 如果选中的那张卡片背面的数字 X ...
- hdu 4550 贪婪 思考题 权
http://acm.hdu.edu.cn/showproblem.php?pid=4550 想了挺久,然后各种分类 最终AC,假设是现场,对自己没信心的话,预计还是要WA,,,,,,然后搜题解,发现 ...
- HDU 5715 XOR 游戏 二分+字典树
XOR 游戏 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5715 Description 众所周知,度度熊喜欢XOR运算(XOR百科). 今天,它 ...
随机推荐
- Linux下报 java.net.SocketException权限不够 异常解决
转载自:http://wangchongan.com/articles/java-net-socket-exception-permission-denied.html 今天在Linux下用Jetty ...
- 一些正则在js使用方法
输入框直接正则判断 <input type="password" name="pwd" placeholder="密码只能以数字\英文\@\.& ...
- Demo_玩家移动(主要注意动画的设置)
using UnityEngine; using System.Collections; public class NewPlayerMove : MonoBehaviour { private fl ...
- Project Euler:Problem 55 Lychrel numbers
If we take 47, reverse and add, 47 + 74 = 121, which is palindromic. Not all numbers produce palindr ...
- josn 转php
$data = josn_decode(data,[true]); 加true转化为php数组:不加为对象,使用:$data->'字段'.
- Apache MINA 框架之Handler介绍
IoHandler 具备以下几个功能: sessionCreated sessionOpened sessionClosed sessionIdle exceptionCaught messageRe ...
- Manacher算法求回文半径
http://wenku.baidu.com/link?url=WFI8QEEfzxng9jGCmWHoKn0JBuHNfhZ-tKTDMux34CeY8UNUwLVPeY5HA3TyoKU2XegX ...
- 数据库 ORM框架 ORMLite
几个ORM框架的比较 先介绍一下ORM的概念,以前也一直听说,不过没详细了解啥意思.其全称叫做对象关系映射(Object Relation Mapping),是一种程序设计技术,用于实现面向对象编程语 ...
- 进程外session(session保存在sqlserver)
.Session保存在SQLServer中配置方法 )运行.NetFramework安装目录下对应版本的aspnet_regsql.exe 来创建相关的数据库.表和存储过程等,比如: C:\Windo ...
- 自己编写SqlHelper
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.W ...