Imran1107048

B

Dec 20th, 2020 (edited)
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 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 unsigned 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 = 1e18;
  12. const int N = 205;
  13.  
  14. bool isvalid(int n)
  15. {
  16. int a[12] = {0};
  17. int temp = n;
  18. while(temp>0){
  19. a[temp%10] = 1;
  20. temp/=10;
  21. }
  22. for(int i=2;i<10;i++){
  23. if(a[i]!=0 && n%i!=0)
  24. return false;
  25. }
  26. return true;
  27. }
  28. void solve();
  29. int32_t main()
  30. {
  31. IOS;
  32. cout << fixed << setprecision(10);
  33. int _ = 1;
  34. cin >> _;
  35. while(_--) solve();
  36. return 0;
  37. }
  38.  
  39. void solve()
  40. {
  41. int n;
  42. cin >> n;
  43. for(int i=n;;i++){
  44. if(isvalid(i)){
  45. cout << i << endl;
  46. break;
  47. }
  48. }
  49. }
  50.  
  51. ///Must see the constraints range
  52. ///Calculate the Time
  53.  
Add Comment
Please, Sign In to add comment