uva 11100 The trip
来源:互联网 发布:js radio disabled 编辑:程序博客网 时间:2024/05/22 04:44
题意:给你n个数字,代表n个包的大小。小的包可以嵌套在大的包里,现在使这些包进行嵌套,使得到最少的包。
方法:找到重复次数最多的数字,包裹数就是重复的次数k。稍微难的是包裹嵌套的输出。一个要求就是这些包裹肯定不能重复,既不能有两个相等。可以想到等差数列,让公差就是k,这样重复最多的数字都不会重复,其他的就更不会重复了。
/*********************************************** * Author: fisty * Created Time: 2015/1/10 9:55:59 * File Name : uva11100.cpp *********************************************** */#include <iostream>#include <fstream>#include <cstring>#include <climits>#include <deque>#include <cmath>#include <queue>#include <stack>#include <list>#include <map>#include <set>#include <utility>#include <sstream>#include <complex>#include <string>#include <vector>#include <cstdio>#include <bitset>#include <functional>#include <algorithm>using namespace std;typedef long long LL;#define MAX_N 10010#define Debug(x) cout << #x << "x" << x <<endlconst int INF = 0x3f3f3f3f;int n;int arr[MAX_N];int num[1000100];int main() { //freopen("in.txt", "r", stdin); cin.tie(0); ios::sync_with_stdio(false); while(scanf("%d", &n) != EOF){ if(!n) break; int _max = 0; memset(arr, 0, sizeof(arr)); memset(num, 0, sizeof(num)); for(int i = 0;i < n; i++){ scanf("%d", &arr[i]); num[arr[i]]++; _max = max(_max, num[arr[i]]); } sort(arr, arr + n); cout << _max << endl; for(int i = 0;i < _max; i++){ int j = i; cout << arr[j]; for(j += _max; j < n; j += _max){ cout << " " << arr[j]; } cout << endl; } } return 0;}
0 0
- UVA 11100 The Trip
- uva 11100 The trip
- Uva 11100 The Trip
- UVa 11100 The Trip
- uva 11100- The Trip
- 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
- 可变参数宏
- 【数学建模】数学建模(一)——数学模型概述
- Take Action Today
- xcode release 和 debug 模式造成的不同
- 数据结构
- uva 11100 The trip
- linux cpu占用率
- Spring Hello World 实例
- oc - 数组及字符串拼接与分割
- C语言中文网《c,c++,linux,mysql...》
- 从头开始写java--第一篇:为什么要做这个事情
- 《C语言及程序设计》实践项目——数据的输出
- 循环-01. 求整数段和(15)
- Java 访问修饰符