TJU Problem 2857 Digit Sorting
原题:
2857. Digit Sorting
Time Limit: 1.0 Seconds Memory Limit: 65536K
Total Runs: 3234 Accepted Runs: 1704
number, writes it down (in decimal notation, without leading zeroes) and sorts
the digits of the notation in non-decreasing order, obtaining another number.
The player who receives the largest number wins.
You are given the list of numbers initially chosen by the players. Output the
winner's resulting number.
Input
The first line of each test case contains an integer N (1 ≤
N ≤ 50), indicating the number of the players. Then N integers
followed in the second line. Each number will be between 0 and 100000,
inclusive.
The input is terminated with N = 0.
Output
Output one line for each test case, indicating the winner's
resulting number.
Sample Input
6
1 10 100 1000 10000 100000
3
9638 8210 331
0
Sample Output
1
3689
Source: TJU Team
Selection Contest 2007 (1)
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std; int num[];
int b[]; int main() {
int N;
memset(b, , sizeof(b));
while (cin >> N && N != ) {
for (int k = ; k < N; k++) {
memset(num, , sizeof(num));
int n, count = ; cin >> n;
for (int i = ; i < ; i++) {
num[i] = n % ;
n /= ; count++;
if (n == ) break;
}
sort(num, num + count);
//9for (int i = 0; i < count; i++) cout << "num["<<i<<"] "<<num[i]<<endl;
//memcpy(b, num, sizeof(b));
//cout << "b["<<k<<"] "<<b[k] << endl;
for (int i = ; i < count; i++) {
if (num[i] != ) b[k] = b[k]* + num[i];
}
//cout << "b["<<k<<"] "<<b[k] << endl;
}
sort(b, b + N);
cout << b[N - ] << endl;
memset(b, , sizeof(b));
}
return ;
}
TJU Problem 2857 Digit Sorting的更多相关文章
- TJU Problem 1015 Gridland
最重要的是找规律. 下面是引用 http://blog.sina.com.cn/s/blog_4dc813b20100snyv.html 的讲解: 做这题时,千万不要被那个图给吓着了,其实这题就是道简 ...
- TJU Problem 1100 Pi
注: 1. 对于double计算,一定要小心,必要时把与double计算相关的所有都变成double型. 2. for (int i = 0; i < N; i++) //N 不 ...
- TJU Problem 2101 Bullseye
注意代码中: result1 << " to " << result2 << ", PLAYER 1 WINS."<& ...
- TJU Problem 2548 Celebrity jeopardy
下次不要被长题目吓到,其实不一定难. 先看输入输出,再揣测题意. 原文: 2548. Celebrity jeopardy Time Limit: 1.0 Seconds Memory Lim ...
- TJU Problem 1065 Factorial
注意数据范围,十位数以上就可以考虑long long 了,断点调试也十分重要. 原题: 1065. Factorial Time Limit: 1.0 Seconds Memory Limit ...
- TJU Problem 2520 Quicksum
注意: for (int i = 1; i <= aaa.length(); i++) 其中是“ i <= ",注意等号. 原题: 2520. Quicksum Time L ...
- TJU Problem 1090 City hall
注:对于每一横行的数据读取,一定小心不要用int型,而应该是char型或string型. 原题: 1090. City hall Time Limit: 1.0 Seconds Memory ...
- TJU Problem 1644 Reverse Text
注意: int N; cin >> N; cin.ignore(); 同于 int N; scanf("%d\n",&N); 另:关于 cin 与 scanf: ...
- Project Euler:Problem 34 Digit factorials
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145. Find the sum of all numbers which are ...
随机推荐
- HTML5-form表单
什么是表单? 01.获取用户的输入 ==>收集数据 02.将用户的输入发送到服务器 ==>与服务器进行交互 相关属性: action:我们收集完用户的信息之后,需要提交的服务器地址 ...
- spring boot开发 静态资源加载不出来
spring boot 1.5 版本之前 不拦截静态资源 springboot 2.x版本 拦截静态资源 private static final String[] CLASSPATH_RESOURC ...
- 【Mac】小技巧:实现ssh服务器别名免密登录
前言 我们平常使用ssh user@host然后输入密码的方式来远程链接一个服务器,但是,如果要管理的服务器太多,记住这些服务器的IP和用户名.密码就是一个复杂的工作.当然,我们可以把这些信息用文档记 ...
- 新概念 Lesson 5 How are you today
How is Emma? 艾玛身体还好吗? 短语:very well How's Emma? She's very well, too. Emma is very well today adv. ...
- node搭建本地服务器
随着前端不断发展,node基本已经成为必备,在调试的时候经常需要服务器,在之前的做法通常是去下载一个phpstudy 或者 xampp等启动一个服务,作为一个前端人虽然可以借助各种工具,但是怎么能不懂 ...
- 铺音out1
1◆ 单个 c k s tʃ g gg g dʒ 2◆ 多个 si dʒ su wr w wh sc s ph f gh ck ʃ ch sh tc ...
- winform窗体this方式和handle(句柄)方式的区别
我们来比较winform窗体的this方式和win32api handle方式实现窗体的最大化.默认窗体.半透明.不透明的区别 1.窗体界面设计 this方式按钮: btnMaxWindow. btn ...
- hadoop hadoop install (1)
vmuser@vmuser-VirtualBox:~$ sudo useradd -m hadoop -s /bin/bash[sudo] vmuser 的密码: vmuser@vmuser-Virt ...
- 快速切题 poj3026
感受到出题人深深的~恶意 这提醒人们以后...数字后面要用gets~不要getchar 此外..不要相信那个100? Borg Maze Time Limit: 1000MS Memory Lim ...
- Keil 中文显示乱码解决办法
在将代码文件转换成UTF-8之前还要把Keil的环境也设置成UTF-8的模式,方法是:“Edit”——〉“Configuration...”——〉“Encoding”,选择“Encode in UTF ...