Round#91 A. Lucky Division|Codeforces
Problem - 122A - Codeforcesを解きました。
#include <bits/stdc++.h> #define REP(i,n) for(int i=0; i<(n); i++) using namespace std; struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star; bool check( int N ){ string S = to_string( N ); REP( i, (int)S.size() ) { if( S[i] != '4' && S[i] != '7' ) return false; } return true; } int main() { int N{}; cin >> N; cout << ( check( N ) || N % 4 == 0 || N % 7 == 0 || N % 47 == 0 || N % 74 == 0 ? "YES" : "NO" ) << endl; return 0; }
lucky digits が 4 と 7。
lucky digitsのみで構成されるNとlucky digitsで割り切れるNがlucky。