Advertisement
Saleh127

atc 042C

Sep 3rd, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; while(t--)
  5. ll a[12]={0};
  6. ll valid(ll x)
  7. {
  8.  
  9. while(x)
  10. {
  11. ll r=x%10;
  12. if(a[r]==1)
  13. {
  14. return 0;
  15. }
  16. x/=10;
  17. }
  18. return 1;
  19. }
  20. int main()
  21. {
  22. ios_base::sync_with_stdio(0);
  23. cin.tie(0);cout.tie(0);
  24.  
  25. ll c,d,i,j,k;
  26. cin>>c>>d;
  27. for(i=0;i<d;i++)
  28. {
  29. cin>>j;
  30. a[j]=1;
  31. }
  32. for(i=c; ;i++)
  33. {
  34. if(valid(i))
  35. {
  36. cout<<i<<endl;
  37. return 0;
  38. }
  39. }
  40.  
  41. return 0;
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement