回文数(牛客最小回文数去除前导0)***
#include<iostream>
using namespace std;
signed main(){
string a, b;
for(int i = 0; i < 10; ++i){
int n; cin >> n;
if(n & 1) b += ('0' + i);
for(int j = 0; j < n / 2; ++j) a += ('0' + i);
}
if(b.size() > 1) cout << -1 << endl;
else{
int index = 0;
while(index < a.size() && a[index] == '0') ++index;
if(index == a.size() && index) cout << -1 << endl;
else{
swap(a[0], a[index]);
cout << a << b;
for(int i = a.size() - 1; i >= 0; --i) cout << a[i];
}
}
return 0;
}

浙公网安备 33010602011771号