原题:

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. 使用 CSS 选择器从网页中提取数据

    在 R 中,关于网络爬虫最简单易用的扩展包是 rvest.运行以下代码从 CRAN 上安装:install.packages("rvest")首先,加载包并用 read_html( ...

  2. 通过 sqldf 包使用 SQL 查询数据框

    在前面的章节中,我们学习了如何编写 SQL 语句,在关系型数据库(如 SQLite 和MySQL )中查询数据.我们可能会想,有没有一种方法,能够直接使用 SQL 进行数据框查询,就像数据框是关系型数 ...

  3. 会话技术及jsp概述

    一.会话技术 1.概念:在一次会话中共享数据,在web中指,浏览器和服务器的一次通信.包含多次请求,和多次响应. 可以在一次会话的多次请求中共享数据. 2.客户端会话技术:Cookie 将数据保存在客 ...

  4. WPF 的 数据源属性 和 数据源

    (一)数据源(数据对象)属性 :path 或  path的值(path=VM.Property或M.Property),通常具有通知功能(特例除外). (二)path不能孤立而存在,它一定具有所归属的 ...

  5. Android之RecyclerView实现时光轴

    做项目的过程中有个需求需要时光轴,于是网上找了部分资料 ,写了个案例,现在分享给大家. 如图: activity_main.xml <?xml version="1.0" e ...

  6. java.lang.UnsupportedClassVersionError: com/my/test/TestUser : Unsupported major.minor version 52.0

    问题原因: 1.执行代码的jdk版本 低于 编译的jdk版本 2.项目用JDK1.8运行过,现在又在本地的eclipse等开发工具或者本地环境变量为低版本的jdk1.7或者jdk1.6下运行,ecli ...

  7. 主席树学习笔记-hdu-2665

    主席树就是对每个历史版本都建了一颗线段树,这样我们在统计一些问题的时候,对于一个区间[L,R]的询问,就可以利用前缀和的思想找到第L-1和第R颗历史版本的线段树来处理查找.由于这样空间需求就增大了,注 ...

  8. Authentication failed (rejected by the remote node), please check the Erlang

    官网提供的解决方案 Synchronise Erlang Cookies (when running a manually installedWindows Service) Erlang Secur ...

  9. python学习笔记(七)---编辑器pycharm的安装

    百度经验网址: https://jingyan.baidu.com/article/0f5fb0993624176d8234ea6c.html 其中 添加 “0.0.0.0 account.jetbr ...

  10. Phython笔记初识

    Phython笔记初识   Python 1898 第一版本 1991 荷兰人 Guido  协议 Gpl                     动态语音类型