Saturday, May 21, 2016

CF 122A

#include<iostream>
#define dbug(x) cout<<">"<<x<<endl;
#include<vector>

using namespace std;

bool isLucky(int n)
{
 int digit;
 while(n!=0)
 {
  digit= n%10;
     if(digit!=7 && digit!=4) return false;
     n=n/10;
 }
 
 return true;
}



int main()
{
 int i,x,j,m,temp;
 vector<int>v;

 for(i=4; i<=500; i++)
 {
  if(isLucky(i)) {
   temp=i;
   v.push_back(temp);
  }
  
 }
 
 while(cin>>x)
 {
  int si;
  if(isLucky(x)){
    cout<<"YES"<<endl;
  }
  
  else{
   
   si=0;
   for(i=0; i<v.size(); i++)
   {
    if(x%v[i]==0){
     si=1;
     break; 
    }
   }
   
   if(si==1) cout<<"YES"<<endl;
   else if(si==0) cout<<"NO"<<endl;
  }
 }
 
 return 0;
}

No comments:

Post a Comment

Thank you for commenting. Please wait for response :)