UVA - 10905 Children's Game
来源:互联网 发布:qq第三方登录 java 编辑:程序博客网 时间:2024/05/17 06:33
题目大意:题意很好懂,问所给数字能组成的最大数是多少。
解题思路:主要是一个编写排序函数 cmp 的技巧,单纯按大小排序再组合显然是行不通的:如 9、90,90 > 9,但显然 909 < 990。这里选择两两组合比较就很简单。
#include<iostream> #include<cstdio>#include<cmath>#include<string.h>#include<stdlib.h>#include<algorithm>#include<queue>#include<map>using namespace std;string num[55];bool cmp (string a, string b) { return a + b > b + a;}int main() { int N; while (scanf("%d", &N)!= EOF && N) { for (int i = 0; i < N; i++) cin >> num[i]; sort(num, num+N, cmp); for (int i = 0; i < N; i++) cout << num[i]; cout << endl; } return 0;}
0 0
- UVa 10905 - Children's Game
- UVa 10905 - Children's Game
- uva 10905 - Children's Game
- uva 10905 - Children's Game
- UVA 10905 Children's Game
- UVa 10905 - Children's Game
- Uva-10905-Children’s Game
- UVa 10905 - Children's Game
- UVa 10905 - Children's Game
- uva 10905 - Children's Game
- UVa 10905 - Children's Game
- uva 10905-Children’s Game
- UVa 10905: Children's Game
- UVA 10905 - Children's Game
- UVA 10905 Children's Game
- UVA 10905 - Children’s Game
- uva 10905 Children's Game
- uva 10905 Children's Game
- 带双参数的双极S型函数
- markdown 基本语法
- 消息推送
- Nginx反向代理-负载均衡讲解与配置
- SAX解析
- UVA - 10905 Children's Game
- LeetCode 44. Wildcard Matching
- targetSdkVersion 23以下6.0中调用checkSelfPermission的问题
- Bugfree安装教程
- wampserver的虚拟主机的配置
- 【Data Structures】 8. Sorting in Java—Comparable and Comparator
- ubuntu解压缩命令
- gitLab简单介绍
- 欢迎使用CSDN-markdown编辑器