码迷,mamicode.com
首页 > 其他好文 > 详细

codeforces水题100道 第十二题 Codeforces Beta Round #91 (Div. 2 Only) A. Lucky Division (brute force)

时间:2016-07-20 17:44:44      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:

题目链接:http://www.codeforces.com/problemset/problem/122/A
题意:判断一个数是否能被一个lucky number整除,一个lucky number是一个只包含4或7的数。
C++代码:

技术分享
#include <cstdio>
int lucky[14] = {4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777};
bool check(int x)
{
    for (int i = 0; i < 14; i ++)
        if (x % lucky[i] == 0)
            return true;
    return false;
}
int main()
{
    int n;
    scanf("%d", &n);
    puts(check(n) ? "YES" : "NO");
    return 0;
}
C++

 

codeforces水题100道 第十二题 Codeforces Beta Round #91 (Div. 2 Only) A. Lucky Division (brute force)

标签:

原文地址:http://www.cnblogs.com/moonlightpoet/p/5689088.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!