UVa 11100 The Trip, 2007 (水题)
来源:互联网 发布:诺基亚软件怎么下载 编辑:程序博客网 时间:2024/05/30 20:09
题目链接:https://vjudge.net/problem/UVA-11100
题目大意:给定n个正整数,把它们划分成尽量少的严格递增序列。
思路:容易知道,严格递增序列的个数就是出现次数最多的数。直接暴力即可。
#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include<cctype>#include <cstdlib>#include<map>#include<iostream>#include<queue>using namespace std;typedef long long LL;const int dr[] = {0,0,-1,1};const int dc[] = {-1,1,0,0};const int maxn = 10000 + 5;int a[maxn], num[maxn*100];int main(){int n;while(scanf("%d", &n) && n){int maxsize = 0;memset(num, 0, sizeof num);for(int i = 0; i < n; i++) {scanf("%d", &a[i]); ++num[a[i]]; maxsize = max(maxsize, num[a[i]]);} sort(a, a+n);printf("%d\n", maxsize);for(int i = 0; i < maxsize; i++){printf("%d", a[i]);for(int j = i+maxsize; j < n; j += maxsize)printf(" %d", a[j]);printf("\n");}}return 0;}
阅读全文
0 0
- 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 - 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
- 如何用好vs2015的调试器 ---- 新手必看
- 1046. 划拳(15)
- 树莓派:安装VNC
- skynet底层源码阅读(8)-启动流程
- C++中虚方法(虚函数)的理解
- UVa 11100 The Trip, 2007 (水题)
- anaconda上安装下opencv
- 51nod 1453 抽彩球
- SSD理解
- [Java]关于Java中的数值计算的简单总结
- 程序员的思维修炼
- 「Machine Learning」Learning Theory from CS229 Lecture Notes
- Spring的Aware
- 转换方向:关于营销