cf A. Jeff and Digits
http://codeforces.com/contest/352/problem/A
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5 6 int n; 7 int a[1001]; 8 int main() 9 { 10 int t1=0,t2=0; 11 scanf("%d",&n); 12 for(int i=1; i<=n; i++) 13 { 14 scanf("%d",&a[i]); 15 if(a[i]==0) t1++; 16 else t2++; 17 } 18 if(t1==0) 19 { 20 printf("-1\n"); 21 } 22 else if(t2<9) 23 { 24 printf("0\n"); 25 } 26 else 27 { 28 for(int i=1; i<=t2/9; i++) 29 { 30 for(int j=1; j<=9; j++) 31 { 32 printf("5"); 33 } 34 } 35 for(int i=1; i<=t1; i++) printf("0"); 36 printf("\n"); 37 } 38 }