Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- ll t;
- cin >> t;
- vector <ll> good;
- for (int i = 1; i <= 9; ++i) {
- good.push_back(i);
- }
- for (int i = 0; i < good.size() && good[i] <= 1e9; ++i) {
- good.push_back(good[i] * 10 + good[i] % 10);
- }
- for (int i = 0; i < t; ++i) {
- cin >> n;
- ll ans = 0;
- for (auto &x : good) {
- if (x <= n) {
- ++ans;
- }
- }
- cout << ans << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement