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;
}
#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;
}
相关文章推荐
- 1.10055 - Hashmat the brave warrior
- 2.10071 - Back to High School Physics
- 3.458 - The Decoder
- 4.694 - The Collatz Sequence
- 6.494 - Kindergarten Counting Game
- 7.490 - Rotating Sentences
- 8.414 - Machined Surfaces
- 9.488 - Triangle Wave
- A.457 - Linear Cellular Automata
- B.489 - Hangman Judge
- C.445 - Marvelous Mazes
- 1.10494 - If We Were a Child Again
- 2.424 - Integer Inquiry
- 3.10250 - The Other Two Trees
- 5.465 - Overflow
- 6.113 - Power of Cryptography
- 7.10161 - Ant on a Chessboard
- 8.621 - Secret Research
- 9.401 - Palindromes
- A.537 - Artificial Intelligence?