Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. int main() {
  2. ios::sync_with_stdio(false);
  3. cin.tie(nullptr);
  4. ll t;
  5. cin >> t;
  6. vector <ll> good;
  7. for (int i = 1; i <= 9; ++i) {
  8. good.push_back(i);
  9. }
  10. for (int i = 0; i < good.size() && good[i] <= 1e9; ++i) {
  11. good.push_back(good[i] * 10 + good[i] % 10);
  12. }
  13. for (int i = 0; i < t; ++i) {
  14. cin >> n;
  15. ll ans = 0;
  16. for (auto &x : good) {
  17. if (x <= n) {
  18. ++ans;
  19. }
  20. }
  21. cout << ans << '\n';
  22. }
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement