rengetsu

CF_122A

Nov 4th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. // Codeforces Round 122A
  2. #include <iostream>
  3. using namespace std;
  4. int Happy(int n)
  5. {
  6.     double q=1, z;
  7.     int ans=0;
  8.     while(q!=1001)
  9.     {
  10.         z=n/q;
  11.         if(z == int(z))
  12.         {
  13.             if(q==4 || q==7 || q==44 || q==47 || q==74 || q==77 || q==444 || q==447 || q==474 || q==477 || q==744 || q==747 || q==774 || q==777)
  14.             {
  15.                 ans=1;
  16.             }
  17.         }
  18.         q++;
  19.     }
  20.     if(ans==1){cout<<"YES";}else{cout<<"NO";}
  21.     return ans;
  22. }
  23. int main()
  24. {
  25.     int n;
  26.     cin >> n;
  27.     if(n==4 || n==7 || n==44 || n==47 || n==74 || n==77 || n==444 || n==447 || n==474 || n==477 || n==744 || n==747 || n==774 || n==777)
  28.     {
  29.         cout << "YES";
  30.     }
  31.     else
  32.     {
  33.         Happy(n);
  34.     }
  35.     return 0;
  36. }
Add Comment
Please, Sign In to add comment