Advertisement
Imran1107048

aa

Dec 20th, 2020
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  5. #define int long long
  6. #define endl "\n"
  7. #define PI acos(-1.0)
  8. #define all(v) v.begin(), v.end()
  9. #define IN freopen("input.txt",'r',stdin)
  10.  
  11. const int INF = 1e9+5;
  12. const int N = 205;
  13.  
  14. void fair(int n)
  15. {
  16. int temp = n;
  17. while(temp>0){
  18. int digit = temp %10;
  19. if(digit!=0 && n%digit!=0){
  20. n++;
  21. fair(n);
  22. }
  23. else
  24. temp /= 10;
  25. }
  26. cout << n << endl;
  27. //return n;
  28. }
  29. void solve();
  30. int32_t main()
  31. {
  32. IOS;
  33. cout << fixed << setprecision(10);
  34. int _ = 1;
  35. cin >> _;
  36. while(_--) solve();
  37. return 0;
  38. }
  39.  
  40. void solve()
  41. {
  42. int n;
  43. cin >> n;
  44. fair(n);
  45. //cout << fair(n) << endl;
  46. }
  47.  
  48. ///Must see the constraints range
  49. ///Calculate the Time
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement