#include<iostream> #include<utility> #include<vector> #include<algorithm> int main() { using namespace std; for (int n; cin >> n;) { vector<pair<int, int>> vec; for (int k =9, i{1}, j;k > 0 && cin >> j;--k,++i) { vec.push_back({ i,j }); } int minx = vec[0].second; for (const auto& p : vec) { minx = minx > p.second ? p.second : minx; } for (int bit = n / minx;bit > 0;--bit) { auto iter = find_if(vec.rbegin(), vec.rend(), [n, bit, minx](pair<int, int> big) {return big.second <= n - (bit-1)*minx;}); n -= iter->second; cout << iter->first; } cout << '\n'; } }