Advertisement
Zeinab_Hamdy

Untitled

Jul 11th, 2022
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.49 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. #define ull unsigned long long
  4. #define nl cout<<"\n";
  5. #define sp cout<<" ";
  6. #define sz(x) x.size()
  7. #define NumOfDigit(w) log10(w) + 1
  8. #define MOD 1'000'000'007
  9. #define inf 2'000'000'000
  10. #define PI 3.141592654
  11. #define modulo(a, b, mod) ((((a) % (mod)) + ((b) % (mod))) % (mod))
  12. #define ceil(w, m) (((w) / (m)) + ((w) % (m) ? 1 : 0))
  13. #define all(v) v.begin(), v.end()
  14. #define rall(v) v.rbegin(), v.rend()
  15. #define cin(v) for (auto&i:v) cin >> i;
  16. #define cout(v) for (auto&i:v) cout << i << " ";
  17. #define fixed(n) fixed << setprecision(n)
  18. using namespace std;  
  19. void zainab_hamdy(){
  20.   ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  21.  //freopen("collisions.in" , "r" ,stdin);
  22.   #ifndef ONLINE_JUDGE  
  23.      freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  24.  #endif  
  25.  
  26. }
  27. bool prime(ll n){
  28.   if(n==2 || n==3) return true;
  29.   if(n<2 || n%2==0  ) return false;
  30.   for(int i=3;i<=sqrt(n);i+=2)   if(n%i==0) return false;
  31.   return true;
  32. }
  33.  
  34. int main(){
  35. zainab_hamdy();
  36.  
  37. int t; cin >> t;
  38. while(t--){
  39.    
  40.     ull num; cin >> num;
  41.    
  42.     for(ull i=num ;  ; i++){
  43.         ull n=i;
  44.          bool bl=0;
  45.         string s=to_string(n);
  46.        
  47.         for(int j=0;j<sz(s)  ;j++){
  48.             if(s[j]!='0' &&  n % (s[j]-'0')!=0){
  49.                 bl=1;
  50.                 break;
  51.             }
  52.         }
  53.         if(bl==0){
  54.             cout << n <<"\n";
  55.             break;
  56.         }
  57.     }
  58. }
  59.  
  60.  return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement