Advertisement
amine99

Untitled

Feb 21st, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define loop(i,b,e) for(int i=b;i<=e;i++)
  5. #define reloop(i,e,b) for(int i=e;i>=b;i--)
  6.  
  7. int holes(int n) {
  8.     int h=0;
  9.     if (n == 0)
  10.         return 1;
  11.     while (n != 0) {
  12.         if (n%10 == 0 || n%10 == 6 || n%10 == 9)
  13.            h += 1;
  14.         if (n%10 == 8)
  15.             h += 2;
  16.         n /=10;
  17.     }
  18.     return h;
  19. }
  20.  
  21. int a,b,maxh,ans;
  22.  
  23. int main() {
  24.     cin >> a >> b;
  25.     loop(i,a,b) {
  26.         if (maxh < holes(i)) {
  27.             ans = i;
  28.             maxh = holes(i);
  29.         }
  30.     }
  31.     cout << ans;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement