B - Lucky Division
Problem description
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya calls a number almost lucky if it could be evenly divided by some lucky number. Help him find out if the given number n is almost lucky.
Input
The single line contains an integer n (1 ≤ n ≤ 1000) — the number that needs to be checked.
Output
In the only line print "YES" (without the quotes), if number n is almost lucky. Otherwise, print "NO" (without the quotes).
Examples
Input
47
Output
YES
Input
16
Output
YES
Input
78
Output
NO
Note
Note that all lucky numbers are almost lucky as any number is evenly divisible by itself.
In the first sample 47 is a lucky number. In the second sample 16 is divisible by 4.
解题思路:幸运数字只由4和7组成。题目要求判断输入的数字n是否可以整除这些幸运数字中的某一个,如果可以为"YES",否则为"NO"。幸运数字就先打好表,其最大值不超过1000即可,简单水过!
AC代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,obj[14]={,,,,,,,,,,,,,};
bool flag=false;cin>>n;
for(int i=;i<;++i)
if(n%obj[i]==){flag=true;break;}
if(flag)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return ;
}
最新文章
- Hibernate单向多对一对象关系模型映射
- Coursera台大机器学习基础课程学习笔记2 -- 机器学习的分类
- 通过Eclipse创建SQLite数据库
- svn-主副分支使用
- php cgi 与 cli 区别
- 九款让WordPress成为赚钱利器的广告插件
- 深度学习系列之CNN核心内容
- 数据库复用代码【c3p0配置文件、数据库连接池】
- 我的代码-date
- 「SCOI2015」国旗计划 解题报告
- WebHttpRequest在sharepoint文档库中的使用
- JAVA中String类常用方法 I
- hbase-java-api001
- JS之计时器
- hive lateral view 与 explode详解
- oracle使用随笔
- Replication--对发布修改的一些小总结
- React 学习二 组件
- 【js】typeof与instanceof
- lua的table库