The Water Problem——桶排序思想
来源:互联网 发布:php mvc demo 编辑:程序博客网 时间:2024/06/07 04:42
Think:
1数值位数可用数组表示,思考可否运用桶排序思想
sdut题目链接
The Water Problem
Time Limit: 1000MS Memory Limit: 65536KB
Problem Description
给定n个5位数字,分别把百位上相同的数按样例格式从小到大摆在一起。
简单来说,就是按照百位上的数字输出一个表单,例如12345的百位是3,就放在3的后面,最后依次输出0-9后面所有的数字。
Input
多组输入。
输入数据占两行,每组数据的第一行是一个正整数n(<= 500),第二行有n个5位正整数。
Output
如题目样例所示输出,每行最后记得输出一个-1作为行结束标志。
Example Input
2
12345 56389
Example Output
0: -1
1: -1
2: -1
3: 12345 56389 -1
4: -1
5: -1
6: -1
7: -1
8: -1
9: -1
Hint
Author
2015级《程序设计基础II》计科软件通信期末上机考试2
以下为Accepted代码
#include <stdio.h>#include <string.h>int a[14][100000];int main(){ int n, i, j, t, x; while(scanf("%d", &n) != EOF){ memset(a, 0, sizeof(a)); for(i = 0; i < n; i++){ scanf("%d", &x); t = (x/100)%10; a[t][x]++; } for(i = 0; i <= 9; i++) { printf("%d:", i); for(j = 10000; j < 100000; j++){ while(a[i][j]--) printf(" %d", j); } printf(" -1\n"); } } return 0;}/***************************************************User name: Result: AcceptedTake time: 416msTake Memory: 1532KBSubmit time: 2017-05-03 16:06:52****************************************************/
0 0
- The Water Problem——桶排序思想
- The Water Problem hdoj 5443 (排序)
- hdu5443 The Water Problem
- hdu 5443 The Water Problem
- hdu 5443 The Water Problem
- The Water Problem(RMQ)
- HDU 5443 The Water Problem
- hdu 5443 The Water Problem
- HDU 5443 The Water Problem
- hdu 5443 The Water Problem
- HDU 5443 The Water Problem
- hdu 5443 The Water Problem
- hdu 5443 The Water Problem(长春网络赛——暴力)
- HDU5443——The Water Problem(2015年长春区域赛)
- HDU 5867 Water problem——模拟
- LeetCode—365. Water and Jug Problem
- HDU 5443 The Water Problem 签到
- HDU 5443 The Water Problem(线段树水题)
- Hadoop01-搭建
- AOJ.860 砝码
- 递归神经网络问题整理
- caffe实战,deep retinal image understanding 实现
- 如果笔记本的 WIN7 运行很卡,请尝试运行这些批处理
- The Water Problem——桶排序思想
- oracle日期英文
- windows下网络诊断基本命令
- 有赞 App 模块化实战经验总结
- SQLServer跨库查询--分布式查询
- A child container failed during start报错原因
- C++作业5
- C++作业五
- linux命令之xargs