fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4.  
  5. ll t, n, res = LLONG_MAX;
  6.  
  7. void kt(ll x,ll s)
  8. {
  9. if(s % n == 0)
  10. {
  11. res = min(res, s);
  12. return;
  13. }
  14. if(x > 13) return;
  15. kt(x + 1, s * 10);
  16. kt(x + 1, s * 10 + 9);
  17. }
  18.  
  19. int main()
  20. {
  21. ios_base::sync_with_stdio(false);
  22. cin.tie(0);cout.tie(0);
  23.  
  24. cin >> t;
  25. while(t--)
  26. {
  27. cin >> n;
  28. kt(1, 9);
  29. cout << res << '\n';
  30. res = LLONG_MAX;
  31. }
  32. return 0;
  33. }
  34.  
Success #stdin #stdout 0s 5324KB
stdin
3
5
7
1 
stdout
90
9009
9