题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1433
数论关于3的倍数有一个推论,就是能被9整除的数的各位和都是9。所以找到5的个数*5的最大的9的倍数,后面全补0。当然前面的判断也是需要的
#include <bits/stdc++.h>
using namespace std; int n, x; int main() {
// freopen("in", "r", stdin);
scanf("%d", &n);
int c5 = , c0 = ;
for(int i = ; i < n; i++) {
scanf("%d", &x);
if(x == ) c5++;
if(x == ) c0++;
}
if(c0 == ) puts("-1");
else if(c5 < ) puts("");
else {
int c = c5 - c5 % ;
while(c--) printf("");
while(c0--) printf("");
}
}