// compile: g++ -o data data.cpp -std=gnu++20 -DLOCAL
// run: ./data < data.in
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#ifdef LOCAL
#endif
#define sz(v) ((int)(v).size())
#define PV(v) for (int i=0;i<v.size();++i)cout<<v[i]<<" ";cout<<endl;
#define int long long
using namespace std;
vector<int> L, R, lst;
int len, minans = 11;
void to_vector(int x, vector<int> &v) {
v.clear();
for (; x; x /= 10) v.push_back(x % 10);
reverse(v.begin(), v.end());
}
bool less_than(vector<int> &a, vector<int> &b) {
if (sz(a) < sz(b)) return 1;
else if (sz(a) > sz(b)) return 0;
for (int i = 0; i < sz(a); ++i) {
if (a[i] < b[i]) return 1;
else if (a[i] > b[i]) return 0;
}
return 1;
}
bool greater_than(vector<int> &a, vector<int> &b) {
if (sz(a) > sz(b)) return 1;
else if (sz(a) < sz(b)) return 0;
for (int i = 0; i < sz(a); ++i) {
if (a[i] > b[i]) return 1;
else if (a[i] < b[i]) return 0;
}
return 1;
}
void check(vector<int> &v) {
if (!greater_than(v, L) || !less_than(v, R)) return;
int minv = 11, maxv = -1;
for (auto it = v.begin(); it!= v.end(); ++it) {
minv = min(minv, *it);
maxv = max(maxv, *it);
}
if (maxv - minv < minans) {
minans = maxv - minv;
lst = v;
}
}
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int _; cin >> _;
while (_--) {
minans = 11;
int l, r; cin >> l >> r;
to_vector(l, L); to_vector(r, R);
if (sz(R) > sz(L)) {
for (int i = 0; i < sz(L); ++i) cout << 9;
cout << endl;
continue;
}
len = sz(L);
vector<int> ans(len, -1);
int p = 0;
for (; p < len && L[p] == R[p]; ++p) ans[p] = L[p];
int remain = len - p;
for (int i = 0; i <= remain; ++i) {
int j;
for (j = p; j < p + i; ++j) ans[j] = L[j];
for (int k = 0; k < 10; ++k) {
for (int q = j; q < len; ++q) ans[q] = k;
check(ans);
}
for (j = p; j < p + i; ++j) ans[j] = R[j];
for (int k = 0; k < 10; ++k) {
for (int q = j; q < len; ++q) ans[q] = k;
check(ans);
}
}
for (int i = 0 ; i < sz(lst); ++i) cout << lst[i];
cout << endl;
}
return 0;
}
Spent quite a bit of time testing different sites and this one stands out for its fair gameplay and quick payouts. The pokie selection is fantastic and I never wait long to cash out. A solid pick for casual gamers. authepokies
I have tried dozens of betting platforms over the years and bh88 stands out because they keep it simple. No confusing menus or hidden fees just solid games and quick payouts. I logged in on a rainy Tuesday and walked away with a nice little bonus before dinner. This really is a breath of fresh air bh88
Had some trouble with other apps crashing on me but this one runs like clockwork every time. The update notifications keep me in the loop with fresh features and I appreciate how transparent they are about their policies. Really solid experience so far apkoxbet