PAT (Advanced Level) 1038. Recover the Smallest Number (30)
注意前导零的消去。
#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)相关推荐
- PAT甲级1038 Recover the Smallest Number (30 分):[C++题解]贪心、排列成最小的数、字符串
文章目录 题目分析 题目来源 题目分析 来源:acwing 分析: 贪心: 对于字符串a和b,如果 a+b < b+a (这里+代表字符串中的连接)代表字典序更小.举例 a = 321 , b ...
- 1038. Recover the Smallest Number (30)
1038. Recover the Smallest Number (30) 进行排序,注意comp的写法: #include <iostream> #include <vector ...
- PAT甲级:1038 Recover the Smallest Number
题目描述: Given a collection of number segments, you are supposed to recover the smallest number from th ...
- 1038 Recover the Smallest Number (30分)
题目 Given a collection of number segments, you are supposed to recover the smallest number from them. ...
- 1038 Recover the Smallest Number (30 分)【难度: 中 / 知识点: 贪心 思维】
https://pintia.cn/problem-sets/994805342720868352/problems/994805449625288704 PAT上的这道题的数据有点弱,其它网站上的数 ...
- pat1038. Recover the Smallest Number (30)
1038. Recover the Smallest Number (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHE ...
- A1038 Recover the Smallest Number (30)
Powered by:NEFU AB-IN Link 文章目录 A1038 Recover the Smallest Number (30) 题意 思路 代码 A1038 Recover the Sm ...
- PAT (Advanced Level) Practice - 1107 Social Clusters(30 分)
题目链接:点击打开链接 题目大意:一个"社交集群"是指部分兴趣爱好相同的人的集合.你需要找出所有的社交集群. 解题思路:并查集思路,轮到第几个人时,以它的 id 为 root,然后 ...
- PAT (Advanced Level) Practice 题目集合(1001 ~ 1050)(正在更新)
1001 A+B Format (20 分) 题目大意:计算a+b,结果按照西方的那种写数字的方式输出,从三个数一个逗号那种. #include<bits/stdc++.h> using ...
最新文章
- 开发各种信息管理系统的标准演示数据都帮你整理好了,少了录入演示\测试\模拟数据的烦恼了[提供下载]...
- React Native 红屏之Could not connect to development server.
- 在Android中afinal框架下实现sqlite数据库版本升级的办法
- java 陷阱_Java基础知识陷阱
- SQL——联接分类和本质
- 10张架构图详解数据中台,附全套数据中台PPT
- 一个过滤器不仅解决了会话标识未更新同时还顺带解决了已解密的登录请求
- 创建和管理CVSNT服务器的步骤
- 探究CSS中border-top属性的使用
- Angr安装与使用之使用篇(八)
- 微服务网关SpringCloud Gateway
- editormd富文本编辑器
- html5 js实现ppt制作,impress.js前端制作酷炫ppt详细教程
- 大学生计算机应用大赛广告设计,计算机应用工程系第四届“经纬在线杯”网页广告设计大赛圆满结束...
- 毕业半年,点滴在心中
- 正则表达式匹配连续出现的单词
- STM32点亮led的详细步骤
- 为什么毕业一年了工资还是只有7K
- 基于SSM 和 layui 的增删查改
- PS设计稿如何在手机中快速预览?
热门文章
- PyQt特殊对话框介绍
- java double 的精度_Java Double的精度问题
- 32 位的有符号整数_leetcode 7 整数反转
- hbase 按时刻查询_Hbase查询工具类,根据时间查询数据
- 5s的app显示无法连接服务器,苹果iphone5s手机无法连接App Store问题解决方法汇总...
- 天融信防火墙重置配置_天融信防火墙配置手册
- linux头文件怎么编译,microsoft编译器怎么使用Linux头文件
- mongodb 导入 mysql_将mongodb 数据指定字段导出,然后指定字段导入mysql 实例 及相关问题解决...
- poj 3352Road Construction(无向双连通分量的分解)
- v7000更换电池步骤_ups电源运行中是否可以更换电池?应如何操作呢