原题:

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. Thunder团队--Alpha发布用户报告

    用户数量:12人 以下为用户评论:(注:为了保护用户的姓名权,以下用户名以昵称形式给出.) 用户名(昵称) 用户使用频次 用户评论(以图片展示) 小王 3次 米线 2次 孔小姐 5次 乌乌鸟 2次 永 ...

  2. Symbol的控件模板

    <esriSymbols:TextSymbol x:Name="text1" Text="adadfdf"></esriSymbols:Tex ...

  3. layui的富文本编辑器怎么赋值

    除了上面讲的方法外,还可以使用layedit自带的方法赋值/*** 设置编辑器内容* @param {[type]} index 编辑器索引* @param {[type]} content 要设置的 ...

  4. kubectl管理多个k8s集群

    #把每个k8s集群的json配置文件放到/root/.kube/目录下,改为不同名字,通过--kubeconfig实现不同集群操作 kubectl --kubeconfig=/root/.kube/m ...

  5. Unity3D中的函数方法和解释

    一.刷新函数 Update 当MonoBehaviour启用时,其Update在每一帧被调用. LateUpdate 当Behaviour启用时,其LateUpdate在每一帧被调用. FixedUp ...

  6. 无法使用BIPublisher开发报表

    我的机器是windows7,word版本问word 2010 32bit. 以前BIPublisher(安装的是BIPublisher 10.1.33版本)能正常使用,突然有一天再想使用他的时候,报以 ...

  7. Python 优化第一步: 性能分析实践 使用cporfile+gprof2dot可视化

    拿来主义: python -m cProfile -o profile.pstats to_profile.py gprof2dot -f pstats profile.pstats |dot -Tp ...

  8. js设计模式-观察者模式

    定义: 观察者模式又叫发布订阅模式,它定义了对象间的一种一对多的依赖关系.观察者模式让两个对象松耦合地联系在一起,虽然不太清楚彼此的细节,但这不影响他们之间的互相通信. 思路 定义一个对象,在对象中实 ...

  9. PHP与MYSQL数据库链接方法

    <?php //Mysqli链接数据库的方法 $host='localhost';//主机地址 $dbname='mydata2017';//数据库名 $username='root';//用户 ...

  10. js打开、关闭页面和运行代码那些事

    <!doctype html> <html> <head> <meta charset="utf-8"> <meta name ...