TJU Problem 2857 Digit Sorting
原题:
2857. Digit Sorting
Time Limit: 1.0 Seconds Memory Limit: 65536K
Total Runs: 3234 Accepted Runs: 1704
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)
1 #include <iostream> 2 #include <algorithm> 3 #include <string.h> 4 using namespace std; 5 6 int num[55]; 7 int b[55]; 8 9 int main() { 10 int N; 11 memset(b, 0, sizeof(b)); 12 while (cin >> N && N != 0) { 13 for (int k = 0; k < N; k++) { 14 memset(num, 0, sizeof(num)); 15 int n, count = 0; cin >> n; 16 for (int i = 0; i < 10; i++) { 17 num[i] = n % 10; 18 n /= 10; count++; 19 if (n == 0) break; 20 } 21 sort(num, num + count); 22 //9for (int i = 0; i < count; i++) cout << "num["<<i<<"] "<<num[i]<<endl; 23 //memcpy(b, num, sizeof(b)); 24 //cout << "b["<<k<<"] "<<b[k] << endl; 25 for (int i = 0; i < count; i++) { 26 if (num[i] != 0) b[k] = b[k]*10 + num[i]; 27 } 28 //cout << "b["<<k<<"] "<<b[k] << endl; 29 } 30 sort(b, b + N); 31 cout << b[N - 1] << endl; 32 memset(b, 0, sizeof(b)); 33 } 34 return 0; 35 }
转载于:https://www.cnblogs.com/QingHuan/p/4263791.html
TJU Problem 2857 Digit Sorting相关推荐
- 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 T ...
- NCPC 2012 Problem B Bread Sorting
题意是给一个数列,可以对三个数操作:把最后一个数放到第一个,前两个数后移一位.问最后能否到达相应的目标序列. 比如 1 2 3 会转换为3 1 2,多了两个逆序对. 给出两列数a和b,问a是否能变成b ...
- matlab 日期排序_在Matlab中对数据进行排序(Sorting Data in Matlab)
在Matlab中对数据进行排序(Sorting Data in Matlab) 我试图在Matlab中对以下数据进行排序,但没有得到我需要的预期输出. 这是数据: '1B-3A-5A' '1A-3A- ...
- java python算法_用Python,Java和C ++示例解释的排序算法
java python算法 什么是排序算法? (What is a Sorting Algorithm?) Sorting algorithms are a set of instructions t ...
- 合并排序算法排序过程_合并排序| 用于大型输入的最佳排序算法之一
合并排序算法排序过程 What is sorting? 什么是分类? Sorting allows us to process our data in a more organized and eff ...
- 《算法导论》第二章 入门
2.1 Insertion sort Pseudocode is used to specify a given algorithm in English. Issues of data abstra ...
- ICPC Central Russia Regional Contest (CRRC 19)
ICPC Central Russia Regional Contest (CRRC 19) 文章目录 ICPC Central Russia Regional Contest (CRRC 19) A ...
- Codeforces Round #839 (Div. 3)题解
A. A+B? 直接读入字符串然后把下标0和2的数字提取出来就行 // Problem: A. A+B? // Contest: Codeforces - Codeforces Round #839 ...
最新文章
- [转载]web集群时利用memcache来同步session
- php4种九九乘法表编程,PHP 99乘法表的几种实现代码
- Google怎么做(1.相关提示)
- 登陆界面(jsp)客户端验证
- linux无法将文件移入回收站,linux中使用rm命令将文件移到回收站的方法
- tcp报文格式_腾讯面试中的TCP/IP协议简述+经典面试题
- leetcode 题库894-- 所有可能的满二叉树
- Servlet3.0
- iOS :高德地图SDK配置教程(安装CocoaPods、生成Podfile文件、安装SDK、demo简单使用等)
- C++ TBB concurrent_unordered_map find() at() return static_cast<size_t>( t ) * internal::hash_multip
- APACHE 在windows下的配置
- EMUI10安装java_速升级!荣耀Play推EMUI 9.1正式版更新:方舟编译器和EROFS系统来了 - IT之家...
- 51单片机调整时钟Proteus仿真
- 2019高考(高中)数学必背重点公式大全
- JAVA走上证券行业
- 黑苹果gtx1050显卡驱动问题
- fmri|SPM contrast manager
- Web App与Native App
- 每晚定时重启IIS和数据库服务可节省服务器资源
- 1.人工智能早期知识表示方法