POJ 3617
来源:互联网 发布:淘宝医疗器械经营 编辑:程序博客网 时间:2024/06/10 19:29
题目链接
http://poj.org/problem?id=3617
简单贪心题.每次贪开头和结尾最小的字符即可
#include <iostream>using namespace std;char s[2111];int n;void solve(){ int a=0,b=n-1,i,cnt=0; while(a<=b) { bool flag=false; for(i=0;a+i<=b;i++){ if(s[a+i]<s[b-i]){ flag=true; break; } else if(s[a+i]>s[b-i]){ flag=false; break; } } if(flag) { cout<<s[a++];cnt++; if(cnt%80==0) {cout<<endl;} } else { cout<<s[b--]; cnt++; if(cnt%80==0) {cout<<endl;} } } if(cnt%80) cout<<endl;}int main(){ int i; while(cin>>n) { for(i=0;i<n;i++) cin>>s[i]; solve(); } return 0;}
0 0
- POJ 3617
- poj----3617
- poj 3617
- poj 3617
- POJ 3617
- POJ-3617
- poj 3617
- POJ 3617
- 3617POJ
- poj 3617
- poj 3617
- POJ 3617
- 小比赛(POJ 2992,UVALive 4108,POJ 2263,POJ 3617,HDU 5305,POJ 1988,POJ 1679,POJ 3481)
- poj 3617 贪心
- poj 3617贪心
- POJ 3617 (贪心)
- POJ 3617 贪心
- POJ 3617 (贪心)
- DataGridView的事件CellForMatting的定位
- C语言详解 - 枚举类型
- android 操作数据库使用系统方法
- 基于MINA构建简单高性能的NIO应用
- centos 命令行补全
- POJ 3617
- Linux下的儿童教学软件
- ThreadPool 线程池[c#]
- hdu4814 Golden Radio Base
- CSharp_DevExpress_XtraLayout布局简单实现;
- loadrunner error提示: Action.c(15): Error -27796: Failed to connect to server "XXX"
- 辞职创业?没那么简单
- Linux学习之CentOS(十三)--CentOS6.4下Mysql数据库的安装与配置
- 不需要密码就登陆SSH Server