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 ...
随机推荐
- Jmeter性能测试之一 性能测试的流程和步骤介绍
Step1: 知道在架构上,你要做的性能测试要cover几个部分,如下图,性能测试从用户角度,PC端之后都要要考虑进行的,例如网络,app server,Database等等 N1+N2+N3+N4 ...
- English trip -- VC(情景课)2 C Where's my pencli?
Grammar focus 语法点: in 和 on in the desk 在桌子抽屉里 on the desk 在桌子面上 Practice 练习 Where's my pencil? I ...
- 3-11 《Ruby元编程》第4章block块 3-12
第4章代码块blocks 基础知识 作用域:用代码块携带variables through scopes 通过传递block给instance_eval方法来控制作用域. 把block转换为Proc, ...
- Nikita and stack CodeForces - 756C (栈,线段树二分)
大意: 给定m个栈操作push(x)或pop(), 栈空时pop()无作用, 每个操作有执行的时间$t$, 对于每个$0 \le i \le m$, 输出[1,i]的栈操作按时间顺序执行后栈顶元素. ...
- layui图片显示
有些东西看文档可以实现,但当真不如自己写的实在.所以还是记录下来吧. 1. 图片赋值 <div id="layer-photos-demo" class="laye ...
- Jenkins install
Linux CentOS 7.1 x64 Java 1.8 x64 apache-maven-3.3.9 Installation sudo wget -O /etc/yum.repos.d/jenk ...
- 『Pandas』数据读取&DataFrame切片
读取文件 numpy.loadtxt() import numpy as np dataset_filename = "affinity_dataset.txt" X = np.l ...
- 使用python创建mxnet操作符(网络层)
对cuda了解不多,所以使用python创建新的操作层是个不错的选择,当然这个性能不如cuda编写的代码. 在MXNET源码的example/numpy-ops/下有官方提供的使用python编写新操 ...
- dp入门求最大公共子序列
#include "bits/stdc++.h" using namespace std; ],b[]; ][]; int main() { cin >> a > ...
- 4.2 event
using System; public delegate void DownloadStartHandler(object sender, DownloadStartEventArgs e); // ...