解法一:
暴力
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define endl '\n'
const int N = 1e6;
bool iswu(int n) {
while (n>=555) {
if (n % 1000 == 555)
return true;
n /= 10;
}
return false;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
vector<int> vec;
for (int i = 555; i <= N; i++) {
if (iswu(i))
vec.push_back(i);
}
int t, x;
cin >> t;
while (t--) {
cin >> x;
int p = lower_bound(vec.begin(), vec.end(), x) - vec.begin();
if (vec[p] == x) cout << p + 1 << endl;
else cout << p << endl;
}
return 0;
}