注意前导零的消去。

#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;string s[10000+10];
int n;bool cmp(const string &a, const string &b)
{return a+b<b+a;
}int main()
{cin>>n;for(int i=1;i<=n;i++) cin>>s[i];sort(s+1,s+1+n,cmp);string ans;for(int i=1;i<=n;i++) ans=ans+s[i];int flag=0;for(int i=0;i<ans.size();i++){if(ans[i]!='0'){flag = 1;for(int j=i;j<ans.size();j++) cout<<ans[j];break;}}if(flag==0) cout<<"0";cout<<endl;return 0;
}

转载于:https://www.cnblogs.com/zufezzt/p/5520968.html

PAT (Advanced Level) 1038. Recover the Smallest Number (30)相关推荐

  1. PAT甲级1038 Recover the Smallest Number (30 分):[C++题解]贪心、排列成最小的数、字符串

    文章目录 题目分析 题目来源 题目分析 来源:acwing 分析: 贪心: 对于字符串a和b,如果 a+b < b+a (这里+代表字符串中的连接)代表字典序更小.举例 a = 321 , b ...

  2. 1038. Recover the Smallest Number (30)

    1038. Recover the Smallest Number (30) 进行排序,注意comp的写法: #include <iostream> #include <vector ...

  3. PAT甲级:1038 Recover the Smallest Number

    题目描述: Given a collection of number segments, you are supposed to recover the smallest number from th ...

  4. 1038 Recover the Smallest Number (30分)

    题目 Given a collection of number segments, you are supposed to recover the smallest number from them. ...

  5. 1038 Recover the Smallest Number (30 分)【难度: 中 / 知识点: 贪心 思维】

    https://pintia.cn/problem-sets/994805342720868352/problems/994805449625288704 PAT上的这道题的数据有点弱,其它网站上的数 ...

  6. pat1038. Recover the Smallest Number (30)

    1038. Recover the Smallest Number (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHE ...

  7. A1038 Recover the Smallest Number (30)

    Powered by:NEFU AB-IN Link 文章目录 A1038 Recover the Smallest Number (30) 题意 思路 代码 A1038 Recover the Sm ...

  8. PAT (Advanced Level) Practice - 1107 Social Clusters(30 分)

    题目链接:点击打开链接 题目大意:一个"社交集群"是指部分兴趣爱好相同的人的集合.你需要找出所有的社交集群. 解题思路:并查集思路,轮到第几个人时,以它的 id 为 root,然后 ...

  9. PAT (Advanced Level) Practice 题目集合(1001 ~ 1050)(正在更新)

    1001 A+B Format (20 分) 题目大意:计算a+b,结果按照西方的那种写数字的方式输出,从三个数一个逗号那种. #include<bits/stdc++.h> using ...

最新文章

  1. 开发各种信息管理系统的标准演示数据都帮你整理好了,少了录入演示\测试\模拟数据的烦恼了[提供下载]...
  2. React Native 红屏之Could not connect to development server.
  3. 在Android中afinal框架下实现sqlite数据库版本升级的办法
  4. java 陷阱_Java基础知识陷阱
  5. SQL——联接分类和本质
  6. 10张架构图详解数据中台,附全套数据中台PPT
  7. 一个过滤器不仅解决了会话标识未更新同时还顺带解决了已解密的登录请求
  8. 创建和管理CVSNT服务器的步骤
  9. 探究CSS中border-top属性的使用
  10. Angr安装与使用之使用篇(八)
  11. 微服务网关SpringCloud Gateway
  12. editormd富文本编辑器
  13. html5 js实现ppt制作,impress.js前端制作酷炫ppt详细教程
  14. 大学生计算机应用大赛广告设计,计算机应用工程系第四届“经纬在线杯”网页广告设计大赛圆满结束...
  15. 毕业半年,点滴在心中
  16. 正则表达式匹配连续出现的单词
  17. STM32点亮led的详细步骤
  18. 为什么毕业一年了工资还是只有7K
  19. 基于SSM 和 layui 的增删查改
  20. PS设计稿如何在手机中快速预览?

热门文章

  1. PyQt特殊对话框介绍
  2. java double 的精度_Java Double的精度问题
  3. 32 位的有符号整数_leetcode 7 整数反转
  4. hbase 按时刻查询_Hbase查询工具类,根据时间查询数据
  5. 5s的app显示无法连接服务器,苹果iphone5s手机无法连接App Store问题解决方法汇总...
  6. 天融信防火墙重置配置_天融信防火墙配置手册
  7. linux头文件怎么编译,microsoft编译器怎么使用Linux头文件
  8. mongodb 导入 mysql_将mongodb 数据指定字段导出,然后指定字段导入mysql 实例 及相关问题解决...
  9. poj 3352Road Construction(无向双连通分量的分解)
  10. v7000更换电池步骤_ups电源运行中是否可以更换电池?应如何操作呢