您的位置:首页 > 其它

UVa 11100

2016-06-23 13:38 246 查看
#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;

int n, a[1000100], maxx, temp, cas;

bool bo[1000100];

int main() {

cas = 0;

while (scanf("%d", &n) != EOF && n)

{

for(int i=0;i<n;i++) scanf("%d", &a[i]);

sort(a, a + n);

maxx = temp = 1;

for(int i=0;i<n-1;i++)

{

if (a[i] == a[i + 1]) temp++;

else temp = 1;

if (maxx < temp) maxx = temp;

}

memset(bo,0,sizeof(bo));

if (cas) printf("\n");

printf("%d\n", maxx);

int i;

temp = 0;

while (1)

{

if (temp >= n) break;

for (i = 0; i < n; i++) if(!bo[i]) break;

temp++;

bo[i] = true;

printf("%d", a[i]);

i += maxx;

for (; i < n; i += maxx)

if (!bo[i])

{

printf(" %d", a[i]);

bo[i] = true;

temp++;

}

printf("\n");

}

}

return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  uva