UVA-11462 (计数排序)
2016-07-12 09:36
423 查看
题意:
2e6个数,按从小到大的顺序输出;
思路:
计数排序;
AC代码:
2e6个数,按从小到大的顺序输出;
思路:
计数排序;
AC代码:
#include <bits/stdc++.h> /* #include <vector> #include <iostream> #include <queue> #include <cmath> #include <map> #include <cstring> #include <algorithm> #include <cstdio> */ using namespace std; #define For(i,j,n) for(int i=j;i<=n;i++) #define Riep(n) for(int i=1;i<=n;i++) #define Riop(n) for(int i=0;i<n;i++) #define Rjep(n) for(int j=1;j<=n;j++) #define Rjop(n) for(int j=0;j<n;j++) #define mst(ss,b) memset(ss,b,sizeof(ss)); typedef long long LL; template<class T> void read(T&num) { char CH; bool F=false; for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar()); for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar()); F && (num=-num); } int stk[70], tp; template<class T> inline void print(T p) { if(!p) { puts("0"); return; } while(p) stk[++ tp] = p%10, p/=10; while(tp) putchar(stk[tp--] + '0'); putchar('\n'); } const LL mod=1e9+7; const double PI=acos(-1.0); const LL inf=1e18; const int N=3e5+10; const int maxn=1005; const double eps=1e-10; int n,m; int a[104]; int main() { while(1) { mst(a,0); read(n); int x; if(!n)break; For(i,1,n)read(x),a[x]++; For(i,1,100) { while(a[i]--) { n--; printf("%d",i); if(n>=1)printf(" "); else printf("\n"); } } } return 0; }
相关文章推荐
- maven 使用findbugs 插件
- [BZOJ 3691] 游行
- 这是一个看脸的时代,但最终拼的是实力
- 【ReactNative】react native 中es6语法解析
- poj 2325 Persistent Numbers
- Chrome 插件收集
- (LeetCode)Intersection of Two Arrays --- ???
- 10.5 搜索的优化版
- JAVA正则表达式语法大全
- Cookie 的路径以及 Cookie 域
- Hadoop简单介绍
- SPI总线协议及SPI时序图详解
- 微信分享等api笔记
- 通过JDBC进行简单的增删改查(以MySQL为例)
- 【SSH】利用applicationContext.xml文件结合java代码生成项目所需的数据库
- 无限滚动AdapterViews and RecyclerView
- Android Studio系列教程四--Gradle基础
- IOS Dev Intro - Message Transfer Mechanism
- OC 中 NSLog 函数输出格式
- C#正则表达式转义字符介绍