Codeforces Beta Round #91 (Div. 2 Only) A. Lucky Division

http://codeforces.com/problemset/problem/122/A

题意:在1到1000,找出可以被幸运数字整除的数字。

PS:
因为输入范围较小,遍历所有可能即可。
注意,有些比如444,777,44,77是满足第一行的,就不要写了。

代码:

1
2
3
4
5
6
7
8
9
10
11
12
#include <bits/stdc++.h>
using namespace std;

int main(){
int l;
cin >> l;
cout << (l % 4 == 0 || l % 7 == 0 ||
l % 47 == 0 || l % 74 == 0 ||
l % 474 == 0 || l % 447 == 0 || l % 477 == 0 || l % 747 == 0 ?
"YES" : "NO");
return 0;
}