#embody <bits/stdc++.h>
utilizing
namespace
std;
int
ans = 0;
void
discover(
int
i, vector<
int
>& digits,
int
masks,
int
okay)
{
if
(i == digits.dimension())
return
;
int
temp = 0;
int
pow_of_10 = 1;
for
(
int
j = digits.dimension() - 1; j >= 0; j--) {
int
okay =
pow
(2, j);
if
(!(masks & okay)) {
temp = temp + pow_of_10 * digits[j];
pow_of_10 *= 10;
}
}
if
(temp > okay) {
ans = min(ans, temp);
}
int
subsequent =
pow
(2, i);
discover(i + 1, digits, masks, okay);
discover(i + 1, digits, masks | subsequent, okay);
}
int
GreaterthanK(
int
N,
int
Ok)
{
vector<
int
> digits;
int
M = N;
whereas
(M) {
digits.push_back(M % 10);
M /= 10;
}
reverse(digits.start(), digits.finish());
ans = N;
discover(0, digits, 0, Ok);
return
ans;
}
int
primary()
{
int
N = 121230;
int
Ok = 756;
cout << (GreaterthanK(N, Ok)) << endl;
return
0;
}