原题:

2857.   Digit Sorting


Time Limit: 1.0 Seconds   Memory Limit: 65536K
Total Runs: 3234   Accepted Runs: 1704

Several players play a game. Each player chooses a certain
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的更多相关文章

  1. TJU Problem 1015 Gridland

    最重要的是找规律. 下面是引用 http://blog.sina.com.cn/s/blog_4dc813b20100snyv.html 的讲解: 做这题时,千万不要被那个图给吓着了,其实这题就是道简 ...

  2. TJU Problem 1100 Pi

    注: 1. 对于double计算,一定要小心,必要时把与double计算相关的所有都变成double型. 2. for (int i = 0; i < N; i++)         //N 不 ...

  3. TJU Problem 2101 Bullseye

    注意代码中: result1 << " to " << result2 << ", PLAYER 1 WINS."<& ...

  4. TJU Problem 2548 Celebrity jeopardy

    下次不要被长题目吓到,其实不一定难. 先看输入输出,再揣测题意. 原文: 2548.   Celebrity jeopardy Time Limit: 1.0 Seconds   Memory Lim ...

  5. TJU Problem 1065 Factorial

    注意数据范围,十位数以上就可以考虑long long 了,断点调试也十分重要. 原题: 1065.   Factorial Time Limit: 1.0 Seconds   Memory Limit ...

  6. TJU Problem 2520 Quicksum

    注意: for (int i = 1; i <= aaa.length(); i++) 其中是“ i <= ",注意等号. 原题: 2520.   Quicksum Time L ...

  7. TJU Problem 1090 City hall

    注:对于每一横行的数据读取,一定小心不要用int型,而应该是char型或string型. 原题: 1090.   City hall Time Limit: 1.0 Seconds   Memory ...

  8. TJU Problem 1644 Reverse Text

    注意: int N; cin >> N; cin.ignore(); 同于 int N; scanf("%d\n",&N); 另:关于 cin 与 scanf: ...

  9. 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 ...

随机推荐

  1. McAfee 与 360使用感受

    运维给配的 win 10.4G内存 ,装的 McAfee,每次开机啥事不干内存去了55%, 开齐qq.微信.vscode.浏览器就要冲90%,再多开几个网页电脑就卡得很, 最近,卡死机了.. 然后看了 ...

  2. 理解Fragment的生命周期

    与活动类似,Fragment也有自己的生命周期.理解Fragment的生命周期有助于在Fragment销毁时能恰当地保存其实例,然后在重新创建时能够将其恢复至之前的状态. 下面的“试一试”将研究Fra ...

  3. HDU 6114 Chess

    Chess 思路:求C(n,m),除法取余用乘法逆元算. 代码: #include<bits/stdc++.h> using namespace std; #define ll long ...

  4. 区间数字的按位与 Bitwise AND of Numbers Range

    2018-08-13 22:50:51 问题描述: 问题求解: 首先如果m 和 n不相等,那么必然会有至少一对奇偶数,那么必然末尾是0. 之后需要将m 和 n将右移一位,直到m 和 n相等. 本质上, ...

  5. English trip -- VC(情景课)9 C What are they doing? 他们在做什么?

    Grammar focus 语法点: 以What 开头的问句 What is/is/are he/she/they doing? Cutting the grass. Walking the dog. ...

  6. Professional layer CodeForces - 1103D (状压,gcd)

    大意: 给定$n$元素序列$a$, 现在想要让$gcd(a_1,a_2,...,a_n)=1$. 对于每个$a_i$可以除以一个不超过$k$的因子, 代价为$e_i$, 假设一共选择了$x$个元素去除 ...

  7. 『PyTorch』第三弹重置_Variable对象

    『PyTorch』第三弹_自动求导 torch.autograd.Variable是Autograd的核心类,它封装了Tensor,并整合了反向传播的相关实现 Varibale包含三个属性: data ...

  8. poj3080kmp或者暴力

    The Genographic Project is a research partnership between IBM and The National Geographic Society th ...

  9. TCP-IP详解:Nagle算法

    在使用一些协议通讯的时候,比如Telnet,会有一个字节字节的发送的情景,每次发送一个字节的有用数据,就会产生41个字节长的分组,20个字节的IP Header 和 20个字节的TCP Header, ...

  10. BZOJ-1010 玩具装箱toy (斜率优化)

    题目大意:将n个数分成若干组,并且每组的数在原数组中应是连续的,每组会产生的代价为sum(i)-sum(j)+i-j-1-m,m为已知的常数.求最小代价. 题目分析:定义dp(i)表示将前 i 个元素 ...