MohamedAbdel3al

Unique Number

Sep 23rd, 2021 (edited)
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std ;
  4. #define sz(s) int(s.size())
  5. #define all(v) v.begin() , v.end()
  6. #define imin INT_MIN
  7. #define imax INT_MAX
  8. typedef long long ll ;
  9.  
  10. void ABDEL3AL () {
  11. ios_base::sync_with_stdio(false); cin.tie(nullptr) , cout.tie(nullptr) ;
  12. #ifndef ONLINE_JUDGE
  13. freopen("input.txt" , "r" , stdin) , freopen("output.txt" , "w" , stdout) ;
  14. #endif
  15. }
  16.  
  17.  
  18. int main() {
  19. ABDEL3AL() ;
  20. int t ; cin >> t ;
  21. while (t--) {
  22. int x ; cin >> x ;
  23. int sum = 0 ;
  24. bool right = false ;
  25. for (int i = 1; i <= 70; i++) {
  26. while (i > 0) sum += i % 10 , i /= 10 ;
  27. if (sum == x) {
  28. cout << i ;
  29. right = true ;
  30. break ;
  31. }
  32. }
  33. cout << (right ? "\n" : "-1\n") ;
  34. }
  35. return 0;
  36. }
Add Comment
Please, Sign In to add comment