UVA 11100(p81)----The Trip, 2007
来源:互联网 发布:电脑防火墙软件 编辑:程序博客网 时间:2024/04/30 11:50
#include<bits/stdc++.h>#define debuusing namespace std;const int maxn=1e4+50;int ans,n;int a[maxn];map<int,int> m;void solve(){ sort(a,a+n); printf("%d\n",ans); for(int i=0; i<ans; i++) { printf("%d",a[i]); for(int j=i+ans; j<n; j+=ans) printf(" %d",a[j]); printf("\n"); }}int main(){#ifdef debug freopen("in.in","r",stdin);#endif // debug while(scanf("%d",&n)==1&&n) { ans=0;m.clear(); for(int i=0; i<n; i++) { scanf("%d",&a[i]); if(!m[a[i]]) m[a[i]]=1; else m[a[i]]++; ans=max(ans,m[a[i]]); } solve(); } return 0;}
题目地址:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2041
题解:ans=max(每个数字出现次数),输出则按照ans等差输出。
0 0
- UVA 11100(p81)----The Trip, 2007
- UVA 11100 The Trip, 2007
- UVa 11100 - The Trip, 2007
- UVa 11100 - The Trip, 2007
- uva 11100 - The Trip, 2007
- uva 11100 - The Trip, 2007
- UVA 11100 - The Trip, 2007
- uva 11100 The Trip, 2007
- UVA 11100 - The Trip, 2007
- UVa:11100 The Trip, 2007
- uva 11100 The Trip, 2007
- UVa 11100 - The Trip, 2007
- UVA - 11100 The Trip, 2007
- uva--11100The Trip, 2007
- UVA 11100 The Trip, 2007
- UVA - 11100 The Trip, 2007
- UVa 11100 - The Trip, 2007
- uva 11100 The Trip, 2007
- leetcode---Majority Element
- 在windows(64)下安装php开发环境wamp+yaf框架+phpstorm以及TortoiseGit
- 数据结构学习笔记(一)
- scala(1) 函数 条件表达式 循环
- linux网络
- UVA 11100(p81)----The Trip, 2007
- hdoj 2028Lowest Common Multiple Plus
- myisam和innodb索引实现的不同
- error c4996
- 用户和用户组文件
- Ubuntu在qt下使用caffe的pro写法
- n个骰子点数和及各自出现的概率
- AVL如何保持平衡
- exec函数族