USTC 1122:Millionaire Rank List

1 篇文章 0 订阅

传送门:http://acm.ustc.edu.cn/ustcoj/problem.php?id=1122

Time Limit: 1000ms
Memory Limit: 131072kb

Description

In the wild universe, there lives a race of clever creature. They have high level civilization and control a lot of planets.

As we human, some of us are very rich and the public like to know who are the Top 10. As a journalist of a famous new paper, you are asked to write a program to get the top 10 list.

Input

The input contains only one test case.

The first line contains one integer N (10 <= N <= 1,000,000), which means there are N rich people in the race. The following N lines each contains a integer Mi (Mi >= 0), which means the money of the i-th person.

But as they are universal millionaires, they are very rich, which means the amount of their money can be as large as 10^25.【强迫症要说一下这里我加了一个符号

Note that Mi may have preceding zeros.

Output

Output 10 lines, containing the money of the richest 10 people in descending order. Delete the preceding zeros if they once have. 

Sample Input

11

1

2

3

4

5

6

7

8

9

10

15

Sample Output

15

10

9

8

7

6

5

4

3

2

 

 

题目大意:把最大的10个数找出来

坑点:they are VERY rich, which means the amount of their money can be as large as 10^25,而且还有前导零

思路:大数+部分排序

 

嘛。。今天上课老师说了这个08年的合肥赛区【弱校专场2333【final的学校不能参加,题目戳我萌点不知道是怎么回事!于是就滚来做了

5号去找小光聊了个天,最近任务大概就下来了QAQ做好【首先得做得出来】之后要挂学校网站上供老师下载好紧张啊2333做不好老师不满意的话哈哈哈哈哈哈反正先等任务下来吧。。现在三层架构都有点混乱不过还好能建起来的地步,15号就是下周五漫展好激动啊卧槽!又能见到小伙伴了!又要见到比我小得多的coser了好紧张啊哈哈哈哈哈哈小学生说我小哈哈哈哈哈哈展子穿浴衣好厚一定会热成狗QAQ

 顺便说一下!今天寝室买的洗衣机到了好棒!!!我和竹竹千辛万苦总算…还是不能用,水龙头太粗了插不进进水管2333

 

看我扯蛋好玩么?

 

#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
using namespace std;
string m[1000000];
bool cmp(string a,string b)
{
	int i,lenA=a.length(),lenB=b.length();
	if(lenA!=lenB)
		return lenA>lenB;
	for(i=0;i<lenA;i++)
	{
		if(a[i]!=b[i])
			return a[i]>b[i];
	}
}
int main()
{
	int n,i,cnt;
	char temp[30];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		cnt=0;
		scanf("%s",temp);
		while(temp[cnt++]=='0');
		m[i]=temp+cnt-1;
	}
	partial_sort(m,m+10,m+n,cmp);
	for(i=0;i<10;i++)
		cout<<m[i]<<endl;
	return 0;
}


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值