fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. using namespace std;
  4.  
  5. int main() {
  6. ios_base::sync_with_stdio(false);
  7. cin.tie(nullptr);
  8. #ifndef ONLINE_JUDGE
  9. freopen("input.txt", "r", stdin);
  10. freopen("output.txt", "w", stdout);
  11. #endif
  12. int x,y;
  13. cin>>x>>y;
  14. bool found=false;
  15. for(int i=x;i<=y;i++) {
  16. bool c=true;
  17. int a=i;
  18. int b=i;
  19. while (b!=0) {
  20. a=b%10;
  21. b/=10;
  22. if (a==4||a==7){
  23. c=true;
  24. }
  25. else {
  26. c=false;
  27. break;
  28. }
  29. }
  30.  
  31. if(c==true) {
  32. cout<<i<<" ";
  33. found=true;
  34. }
  35. }
  36. if (found==false) {
  37. cout<<-1<<endl;
  38. }
  39. return 0;}
Success #stdin #stdout 1.64s 5348KB
stdin
Standard input is empty
stdout
0 4 7 44 47 74 77 444 447 474 477 744 747 774 777 4444 4447 4474 4477 4744 4747 4774 4777 7444 7447 7474 7477 7744 7747 7774 7777