fork download
  1. #include <iostream>
  2. #include <cstdio>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. ios_base::sync_with_stdio(false);
  8. cin.tie(nullptr);
  9.  
  10. #ifndef ONLINE_JUDGE
  11. freopen("input.txt", "r", stdin);
  12. freopen("output.txt", "w", stdout);
  13. #endif
  14.  
  15. int x, y;
  16. cin >> x >> y;
  17.  
  18. bool found = false;
  19.  
  20. for (int i = x; i <= y; i++) {
  21. bool c = true;
  22. int a = i;
  23. int b = i;
  24.  
  25. while (b != 0) {
  26. a = b % 10;
  27. b /= 10;
  28.  
  29. if (a == 4 || a == 7) {
  30. c = true;
  31. } else {
  32. c = false;
  33. break;
  34. }
  35. }
  36.  
  37. if (c == true) {
  38. cout << i << " ";
  39. found = true;
  40. }
  41. }
  42.  
  43. if (found == false) {
  44. cout << -1 << endl;
  45. }
  46.  
  47. return 0;
  48. }
Success #stdin #stdout 0s 5348KB
stdin
4 20
stdout
4 7