唯一的坑点在 hash【0】 == n-1,无论如何输出都是-1,其他的正常输出就可以了
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int N = 100005;
int a[N];
int d[15];
int n, m;
int main()
{
while(~scanf("%d", &n))
{
memset(d, 0, sizeof(d));
bool f = 0;
int c = 0;
int x = 11;
for(int i = 1; i <= n; i++)
{
scanf("%d", &a[i]);
if(a[i] == 0)
c++;
if(a[i] % 2)
{
f = 1;
if(a[i] < x)
x = a[i];
}
d[a[i]]++;
}
if(!f)
{
printf("-1\n");
continue;
}
d[x]--;
if(d[0] == n-1 && n > 1)
{
printf("-1\n");
}
else
{
for(int i = 9; i >= 0; i--)
{
while(d[i]--)
printf("%d", i);
}
printf("%d\n", x);
}
}
return 0;
}