首页 > 其他分享 >UVA - 10905 Children's Game 字符串的排序

UVA - 10905 Children's Game 字符串的排序

时间:2023-04-07 11:03:17浏览次数:32  
标签:string int 10905 Game maxn str UVA include cmp


题目大意:给出N个数字串,要求拼出有数字最大的串

解题思路:用string就很好解决

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int maxn = 60;
string str[maxn];

int cmp(string a, string b) {
	return a+b > b+a;
}
 
int main() {
	int n;
	while(scanf("%d", &n) && n) {
		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];	
		cout << endl;	
	}
	return 0;
}



标签:string,int,10905,Game,maxn,str,UVA,include,cmp
From: https://blog.51cto.com/u_10970600/6175574

相关文章

  • UVA - 10706 Number Sequence 子序列
    #include<cstdio>#include<cmath>#include<algorithm>usingnamespacestd;constintmaxn=32761;longlongS[maxn];//存放的是S1,S2,到SK的和,S[5]表示了S1到S4的和,当数字变化到K的时候,一共有多少个字数了intborder[9]={0,1,10,100,1000,10000,100000,1000000,10000000......
  • UVA - 129 Krypton Factor 回溯+剪枝
    题目大意:给出N种字母,要求用这N种字母组成一个困难的串,困难的串指在串中没有相连的两个子串相同,要求输出第M个困难的串解题思路:像八皇后一样,前面判断的就不需要再去判断了,直接往后判断即可#include<cstdio>#include<cstring>intn,L;intans[100];boolflag;intcnt;boolju......
  • JumpGame
    packageDynamicPlanning;/***55.跳跃游戏*给定一个非负整数数组nums,你最初位于数组的第一个下标。*数组中的每个元素代表你在该位置可以跳跃的最大长度。*判断你是否能够到达最后一个下标。*//***设想一下,对于数组中的任意一个位置y,我们如何判断它是......
  • Cyborg Genes UVA - 10723
    求一个最短序列,使得输入的两个串的均为他的子序列,同时输出方案数。  n+m-LCS方案数转移时求#include<iostream>#include<cstring>usingnamespacestd;#defineintlonglongintn,m;chara[102],b[102];intf[102][102],cnt[102][102];signedma......
  • 旅行 Tour uva1347
    直角坐标系中,有nn个点。要求先从左往右走,再从右往左走,不重复的经过每一个点。求出最短路径(距离为两点间直线距离)。 f[i][j]表示点1~max(i,j)已走过,的路径长度 #include<iostream>#include<algorithm>#include<cstring>#include<cmath>#include<iomanip>......
  • python-Pygame 小游戏开发
    AIServoPlatformThisProjectisbaseontheraspberryhardwareplatformwhichbeusedforautomaticfacetrackandalsopersontrackfiledinthefuture.AITech.RaspberryProgramming.HardwareUpdate.1.StoveControlCodeimportpygamefrompygame.lo......
  • E - Transition Game
    E-TransitionGamehttps://atcoder.jp/contests/abc296/tasks/abc296_e思路    Codehttps://atcoder.jp/contests/abc296/submissions/40262511#include<bits/stdc++.h>usingnamespacestd;map<int,vector<int>>mp;intdeg[200006];int......
  • python pygame播放音频文件
    pythonpygame播放音频文件 pipinstallpygame  importpygame#Initializepygamepygame.init()#LoadtheMP3filepygame.mixer.music.load("1.mp3")#PlaytheMP3filepygame.mixer.music.play()#WaitfortheMP3filetofinishplayingwhil......
  • 例题3-2 WERTYU(WERTYU, UVa10082)
    题目把手放在键盘上时,稍不注意就会往右错一位。这样,输入Q会变成输入W,输入J会变成输入K等。键盘如图3-2所示。输入一个错位后敲出的字符串(所有字母均大写),输出打字员本来想打出的句子。输入保证合法,即一定是错位之后的字符串。例如输入中不会出现大写字母A。样例输入OS,GO......
  • 例题3-1 TeX中的引号(Tex Quotes, UVa 272)
    题目在TeX中,左双引号是“``”,右双引号是“''”。输入一篇包含双引号的文章,你的任务是把它转换成TeX的格式。样例输入"Tobeornottobe,"quoththeBard,"thatisthequestion".样例输出``Tobeornottobe,''quoththeBard,``thatisthequestion''.思路依......