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 ...
随机推荐
- ubuntu下安装redis扩展
采用源码编译安装 下载 下载redis源码包到本地一个临时目录 git clone https://github.com/phpredis/phpredis.git 移动文件到合适目录 mv phpr ...
- 图解GitHub
转自:http://marklodato.github.io/visual-git-guide/index-zh-cn.html 个人觉得这一篇比一些入门教程更值得看,图解很详细到位,很容易理解其工作 ...
- Cognos添加关联字段
(这是另一个表)
- how to make a function from using global var to not using it
let say, we want to find the bottom left node in a tree.one way to do it is using global vars: /** * ...
- 数组排序 sort
数组排序 this.dataShow = this.data.sort((a, b) => { return parseInt(a[this.innerOrderBy]) - parseInt( ...
- postman使用--发送请求
概述 上节讲了下接口的基础,从现在来学习怎么测接口.当然,测试接口有很多的工具,比如postman,jmeter等等,或者用代码测试,如果是做接口自动化我当然会选python,如果是调试接口,我特别喜 ...
- 【牛客小白月赛6】F 发电 - 树状数组&快速幂&逆元
题目地址:https://www.nowcoder.com/acm/contest/136/F 树状数组.快速幂.逆元的模板运用: #include<iostream> #include& ...
- 深入Linux内核架构——进程管理和调度(上)
如果系统只有一个处理器,那么给定时刻只有一个程序可以运行.在多处理器系统中,真正并行运行的进程数目取决于物理CPU的数目.内核和处理器建立了多任务的错觉,是通过以很短的间隔在系统运行的应用程序之间不停 ...
- 关于web页面优化
简单汇总了一下web的优化方案(主要的前端优化策略) 减少http请求次数 文件合并(js.css.图片):ps:多个图片合并之后,总体积会变小 内联图片,即data:URL scheme,但容易导致 ...
- Android开发——使用ADB Shell命令实现模拟点击(支付宝自动转账实现)
首先声明,本人反对一切利用技术的违法行为 本文的实现代码已经销毁,本文以介绍流程为主 1.这里所说的模拟点击不是在自己的APP里点击,点自己APP上的控件没什么好说的 不仅是支付宝转账,其他的获取别人 ...