[UVA-11039]Children's Game
解析
微扰法贪心经典题
代码
#include <bits/stdc++.h>
using namespace std;
bool cmp(const string &x, const string &y) {
return x + y > y + x;
}
int main() {
int n;
while (~scanf("%d", &n) && n) {
string str[55];
for (int i = 1; i <= n; ++ i) cin >> str[i];
sort(str + 1, str + n + 1, cmp);
for (int i = 1; i <= n; ++ i) cout << str[i];
putchar(10);
}
}
[UVA-11039]Children's Game的更多相关文章
- uva 10905 Children's Game (排序)
题目连接:uva 10905 Children's Game 题目大意:给出n个数字, 找出一个序列,使得连续的数字组成的数值最大. 解题思路:排序,很容易想到将数值大的放在前面,数值小的放在后面.可 ...
- UVA 10905 Children's Game 孩子的游戏 贪心
题意:给出N个数,要求把它们拼凑起来,让得到的数值是最大的. 只要分别比较两个数放前与放后的值的大小,排序后输出就可以了. 比如123和56,就比较12356和56123的大小就行了. 写一个比较函数 ...
- UVA 11039 Building designing 贪心
题目链接:UVA - 11039 题意描述:建筑师设计房子有两条要求:第一,每一层楼的大小一定比此层楼以上的房子尺寸要大:第二,用蓝色和红色为建筑染色,每相邻的两层楼不能染同一种颜色.现在给出楼层数量 ...
- 贪心水题。UVA 11636 Hello World,LA 3602 DNA Consensus String,UVA 10970 Big Chocolate,UVA 10340 All in All,UVA 11039 Building Designing
UVA 11636 Hello World 二的幂答案就是二进制长度减1,不是二的幂答案就是是二进制长度. #include<cstdio> int main() { ; ){ ; ) r ...
- 【字符串排序,技巧!】UVa 10905 - Children’s Game
There are lots of number games for children. These games are pretty easy to play but not so easy to ...
- UVA 10905 Children's Game (贪心)
Children's Game Problem Description There are lots of number games for children. These games are pre ...
- UVa 10905 - Children's Game 排序,题目没有说输入是int 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- UVa 11039 - Building designing 贪心,水题 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- UVa 10905 - Children's Game(求多个正整数排列后,所得的新的数字的极值)
4thIIUCInter-University Programming Contest, 2005 A Children’s Game Input: standard input Output: st ...
- UVA 11039 - Building designing(DP)
题目链接 本质上是DP,但是俩变量就搞定了. #include <cstdio> #include <cstring> #include <algorithm> u ...
随机推荐
- Java综合高级篇
1.你用过哪些集合类? 大公司最喜欢问的Java集合类面试题 40个Java集合面试问题和答案 java.util.Collections 是一个包装类.它包含有各种有关集合操作的静态多态方法. ja ...
- 转:【专题二】HTTP协议详解
我们在用Asp.net技术开发Web应用程序后,当用户在浏览器输入一个网址时就是再向服务器发送一个HTTP请求,此时就使用了应用层的HTTP协议,在上一个专题我们简单介绍了网络协议的知识,主要是为了后 ...
- Codeforces 841B - Godsend
题目链接:http://codeforces.com/problemset/problem/841/B Leha somehow found an array consisting of n inte ...
- 可视化的fineBI很高大上 使用简单,简单操作了一下,拖一拖就行,收费 只能看一下人家的demo 网站 http://demo.finebi.com/webroot/decision#directory
- C++11 正则表达式简单运用
正则表达式(regular expression)是计算机科学中的一个概念,又称规则表达式,通常简写为regex.regexp.RE.regexps.regexes.regexen. 正则表达式是一种 ...
- ES6知识整理(8)--Promise对象
(关于promise,以前并不知道是什么,没这个概念.现在来学习总结下) promise含义 es6的异步编程解决方案.需要new新对象操作api. promise对象特点 有3中状态:pending ...
- mybatis 3.2.*打印sql结果集
虽然可以写个interceptor记录下,但是总归没有log4j来的自然.一段时间不查问题,总是要忘了,记录下: 在mybatis 3.2.*中,可以在log4j中如下配置: log4j.logger ...
- k8s build new API
apiserver-builder git hub api conventions storage api arch step by step, we can follow it. api con ...
- 【Python045-魔法方法:属性访问】
一.属性的几种访问方式 1.类.属性名 >>> class C: def __init__(self): self.x = 'X-man' >>> c = C() ...
- topcoder srm 320 div1
problem1 link 两个数字后面都有阶乘符号,可以抵消. import java.util.*; import java.math.*; import static java.lang.Mat ...