原题:

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. 在centos下解决 “致命错误:curses.h:没有那个文件或目录”

    当在centos下编译带有头文件<curses.h> 的程序时,出现以下错误: “致命错误:curses.h:没有那个文件或目录” ,最后在“https://zhidao.baidu.co ...

  2. 《剑指offer》第十六题(数值的整数次方)

    // 面试题:数值的整数次方 // 题目:实现函数double Power(double base, int exponent),求base的exponent // 次方.不得使用库函数,同时不需要考 ...

  3. Log4J日志配置详解[转]

    一.Log4j简介 Log4j有三个主要的组件:Loggers(记录器),Appenders (输出源)和Layouts(布局).这里可简单理解为日志类别,日志要输出的地方和日志以何种形式输出.综合使 ...

  4. Codeforces 680D - Bear and Tower of Cubes

    680D - Bear and Tower of Cubes 思路:dfs+贪心,设剩余的体积为res,存在a,使得a3 ≤ res,每次取边长为a的立方体或者边长为a-1的立方体(这时体积上限变成a ...

  5. java通过java.net.URL发送http请求调用接口

    一般在*.html,*.jsp页面中我们通过使用ajax调用接口,这个是我们通常用的.对于这些接口,大都是本公司写的接口供自己调用,所以直接用ajax就可以.但是,如果是多家公司共同开发一个东西,一个 ...

  6. Hadoop生产环境搭建(含HA、Federation)

    Hadoop生产环境搭建 1. 将安装包hadoop-2.x.x.tar.gz存放到某一目录下,并解压. 2. 修改解压后的目录中的文件夹etc/hadoop下的配置文件(若文件不存在,自己创建.) ...

  7. transition多个属性同时渐变(left/top)

    <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head>    < ...

  8. Vue--- 手动禁止ESlint

    使用vue-cli构建项目时,通常会问你要不要 “Use ESlint to lint your code?” 建议使用,这样会有助于规范我们的代码(这也是一种审美),ESlint的规范就不说了,写多 ...

  9. httpclient RequestConfig类

    RequestConfig类解析 这个类位于org.apache.he.http.client.config包下,主要用于获取和配置一些外部的网络环境,它下面有一个嵌套类RequestConfig.B ...

  10. Thinking in Java 之classpath理解

    等待写: <Thinking in Java> page127