10905 - Children's Game】的更多相关文章

题目连接:uva 10905 Children's Game 题目大意:给出n个数字, 找出一个序列,使得连续的数字组成的数值最大. 解题思路:排序,很容易想到将数值大的放在前面,数值小的放在后面.可是,该怎么判断数值的大小(判断数值大小不能单单比较两个数的大小,比如遇到:1 .10的情况).其实,判断一个不行,那就将两个合在一起考虑就可以了(就是比较110合101的大小来普判断1 放前面还是10放前面). #include <stdio.h> #include <string.h>…
题意:给出N个数,要求把它们拼凑起来,让得到的数值是最大的. 只要分别比较两个数放前与放后的值的大小,排序后输出就可以了. 比如123和56,就比较12356和56123的大小就行了. 写一个比较函数,然后用sort调用就行了. 刚开始时用long long做,每次比较都让数相连,然后比较大小,后来发现数据好像会很暴力,即使longlong也不够大. 考虑到两个数相连后两种情况长度都一样,所以只要把数值当成string来做就行了,比较两个string的字典序大小. 代码: /* * Author…
4th IIUC Inter-University Programming Contest, 2005 A Children’s Game Input: standard input Output: standard output Problemsetter: Md. Kamruzzaman There are lots of number games for children. These games are pretty easy to play but not so easy to mak…
There are lots of number games for children. These games are pretty easy to play but not so easy to make. We will discuss about an interesting game here. Each player will be given N positive integer. (S)He can make a big integer by appending those in…
Children's Game Problem Description There are lots of number games for children. These games are pretty easy to play but not so easy to make. We will discuss about an interesting game here. Each player will be given N positive integer. (S)He can make…
4thIIUCInter-University Programming Contest, 2005 A Children’s Game Input: standard input Output: standard output Problemsetter: Md. Kamruzzaman There are lots of number games for children. These games are pretty easy to play but not so easy to make.…
注意!这不是单纯的字典序排序,比如90.9,应该是990最大 对字符串排序蛋疼了好久,因为别人说string很慢,所以一直没有用过. 看别人用string还是比较方便的,学习一下 对了,这里的cmp函数写的还是很简洁的,比我写的要好得多 #define LOCAL #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std;…
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1846 题意 n个数字按照字符串方式直接组合成大数字,问最大组合成多少 思路 排序 感想 1. 因为脑洞的原因以为只要把所有数的数位填到一样长就好了,比如27,273,72,723把27填到272,72填到727,就能把它们顺利排出来.结果这样无法区别345, 3453这种情况和543…
贪心,假如任意给出一个序列,如果两两交换了以后会变大,那么就交换,直到不能交换为止. #include<bits/stdc++.h> using namespace std; ; string s[maxn]; int rk[maxn]; bool cmp(int x,int y) { , j = , n1 = s[x].size(), n2 = s[y].size(); string *s1 = &s[x], *s2 = &s[y]; int ct = n1+n2; whil…
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics 10300 - Ecological Premium 458 - The Decoder 494 - Kindergarten Counting Game 414 - Machined Surfaces 490 - Rotating Sentences 445 - Marvelous Mazes…