fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. void fast_io(){
  7. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  8. #ifndef ONLINE_JUDGE
  9. //freopen("input.txt", "r", stdin);
  10. #endif
  11. }
  12.  
  13. int main()
  14. {
  15. fast_io();
  16. int num;
  17. cin >> num;
  18. int temp = num;
  19. int counter = 0;
  20. int digits = 0;
  21. while (temp > 0){
  22. temp /= 10;
  23. digits++;
  24. }
  25. temp = num;
  26. while (temp > 0){
  27. if (temp%10 == 4 || temp%10 == 7 ){
  28. temp /= 10;
  29. counter++;
  30. }else{
  31. break;
  32. }
  33. }
  34. if (counter == digits){
  35. cout << "YES";
  36. }else{
  37. if (num%7 == 0 || num%4 == 0){
  38. cout << "YES";
  39. }else{
  40. cout << "NO";
  41. }
  42. }
  43.  
  44. }
Success #stdin #stdout 0.01s 5292KB
stdin
47
stdout
YES