PAT (Advanced Level) 1038. Recover the Smallest Number (30)
注意前导零的消去。
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std; string s[+];
int n; bool cmp(const string &a, const string &b)
{
return a+b<b+a;
} int main()
{
cin>>n;
for(int i=;i<=n;i++) cin>>s[i];
sort(s+,s++n,cmp);
string ans;
for(int i=;i<=n;i++) ans=ans+s[i]; int flag=; for(int i=;i<ans.size();i++)
{
if(ans[i]!='')
{
flag = ;
for(int j=i;j<ans.size();j++) cout<<ans[j];
break;
}
} if(flag==) cout<<"";
cout<<endl;
return ;
}
PAT (Advanced Level) 1038. Recover the Smallest Number (30)的更多相关文章
- 【PAT甲级】1038 Recover the Smallest Number (30 分)
题意: 输入一个正整数N(<=10000),接下来输入N个字符串,每个字符串包括至多8个字符,均为数字0~9.输出由这些字符串连接而成的最小数字(不输出前导零). trick: 数据点0只包含没 ...
- pat 甲级 1038. Recover the Smallest Number (30)
1038. Recover the Smallest Number (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHE ...
- PAT 甲级 1038 Recover the Smallest Number (30 分)(思维题,贪心)
1038 Recover the Smallest Number (30 分) Given a collection of number segments, you are supposed to ...
- 1038. Recover the Smallest Number (30)
题目链接:http://www.patest.cn/contests/pat-a-practise/1038 题目: 1038. Recover the Smallest Number (30) 时间 ...
- PAT Advanced 1038 Recover the Smallest Number (30) [贪⼼算法]
题目 Given a collection of number segments, you are supposed to recover the smallest number from them. ...
- PAT 1038 Recover the Smallest Number (30分) string巧排序
题目 Given a collection of number segments, you are supposed to recover the smallest number from them. ...
- 1038. Recover the Smallest Number (30) - 字符串排序
题目例如以下: Given a collection of number segments, you are supposed to recover the smallest number from ...
- 1038 Recover the Smallest Number (30)(30 分)
Given a collection of number segments, you are supposed to recover the smallest number from them. Fo ...
- 1038 Recover the Smallest Number (30分)(贪心)
Given a collection of number segments, you are supposed to recover the smallest number from them. Fo ...
随机推荐
- sybase sql anywhere 5.0 安装后sybase central中无法打开视图等的解决办法
无法打开的原因初步分析要用英文版的xp,后来在如下处发现问题,是sql anywhere的版本太旧了, 可能没有使用Unicode编码,设置一下如下选项可以解决问题.
- 原创 :单刷深渊 在Linux中系统安装mysql实战直播
[root@web108 tools]# ###开始装mysql 1添加用户 [root@web108 tools]# useradd -s /sbin/nologin -M mysql 2解压 [r ...
- TIOJ1208 第K大连续和
第k大的题一般都有点麻烦 pbds库的tree,需要研究一下https://codeforces.com/blog/entry/11080find_by_order() and order_of_ke ...
- oracle插入多表(insert all/first)
1.建测试表 CREATE TABLE EDW_INT ( AGMT_NO VARCHAR2(40 BYTE) NOT NULL, AG ...
- struts2中关于jsp页面向action传值出现乱码问题
在JSP页面输入中文并传给后台的时候,常常会出现乱码问题,产生乱码的原因:java在进行传值的时候,默认用的是iso-8859-1的编码形式进行传输,而我们jsp页面常用的则是utf-8的编码形式.所 ...
- iOS 6 的 Smart App Banners 介绍和使用
iOS 6 的 Smart App Banners 介绍和使用 Denis 留言: 10 浏览:4890 文章目录[隐藏] 什么是 Smart App Banners 在你的网站添加 Smart Ap ...
- C/C++连接MySQL数据库执行查询
1. 简介: 使用C/C++连接MySQL数据库执行增删改查操作,基本就是围绕以下两个文件展开: mysql.h(此头文件一般在MySQL的include文件夹内,如 D:\MySQL\mysql-5 ...
- 条款24:若所有参数皆需要类型转换,请为此采用non-member函数(Declare non-member functions when type conversions should apply to all parameters)
NOTE: 1.如果你需要为某个函数的所有参数(包括this指针所指的那个隐喻参数)进行类型转换,那么这个函数必须是个non-member.
- 条款9:绝不在构造和析构过程中调用virtual函数(Never call virtual functions during construction or destruction)
NOTE:在构造和析构期间不要调用virtual函数,因为这类调用从不下降至derived class(比起当前执行构造函数和析构函数的那层)
- python之多线程与多进程
1. 多进程与多线程 (1)背景:为何需要多进程或者多线程:在同一时间里,同一个计算机系统中如果允许两个或者两个以上的进程处于运行状态,这便是多任务.多任务会带来的好处例如用户边听歌.边上网.边打印, ...