fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. long long t, n, a[10000000];
  5.  
  6. int main()
  7. {
  8. ios_base::sync_with_stdio(false);
  9. cin.tie(NULL);cout.tie(NULL);
  10. a[1] = 9;
  11. for (int i = 2; i <= 4500; i++)
  12. {
  13. if (i%2 == 0) a[i] = 10 * a[i/2];
  14. else a[i] = 10 * a[i/2] + 9;
  15. }
  16.  
  17. cin >> t;
  18. for (int i = 1;i <= t; i++)
  19. {
  20. cin >> n;
  21. for (int i = 1; i <= 4500; i++)
  22. if (a[i] % n == 0)
  23. {
  24. cout << a[i] << '\n';
  25. break;
  26. }
  27. }
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 5304KB
stdin
3
5
7
1 
stdout
90
9009
9