Răspuns :
#include <fstream>
using namespace std;
int x[10] = {12, 5, 11, 11, 9, 11, 12, 7, 13, 12};
int main() {
ifstream cin("imprimanta.in");
ofstream cout("imprimanta.out");
unsigned long long a;
int k, maxcif = -1, minap = 14, nrmaxcif, pramas;
cin >> a >> k;
cin.close();
while (a) {
if (x[a % 10] < minap) {
maxcif = a % 10;
minap = x[a % 10];
}
else
if (x[a % 10] == minap)
if (a % 10 > maxcif)
maxcif = a % 10;
a /= 10;
}
cout << maxcif << '\n';
nrmaxcif = k / 5;
pramas = k % 5;
if (pramas == 0) {
for (int i = 1; i <= nrmaxcif; i++) cout << 1;
return 0;
}
else
if (pramas == 1) {
if (k == 16) {
cout << 74;
return 0;
}
else {
cout << 777;
for (int i = 1; i <= nrmaxcif - 4; i++) cout << 1;
return 0;
}
}
else
if (pramas == 2) {
cout << 7;
for (int i = 1; i <= nrmaxcif - 1; i++) cout << 1;
return 0;
}
else
if (pramas == 3) {
cout << 8;
for (int i = 1; i <= nrmaxcif - 2; i++) cout << 1;
return 0;
}
else {
cout << 77;
for (int i = 1; i <= nrmaxcif - 2; i++) cout << 1;
return 0;
}
}