Sunday, June 29, 2014

Codeforces Beta Round #91 (Div. 2 Only), problem: (A) Lucky Division solution & size/length of array C++

Codeforces Beta Round #91 (Div. 2 Only), problem: (A) Lucky Division: http://codeforces.com/problemset/problem/122/A

Codeforces Beta Round #91 (Div. 2 Only), problem: (A) Lucky Division editorial: http://codeforces.com/blog/entry/2956

Codeforces Beta Round #91 (Div. 2 Only), problem: (A) Lucky Division solution: http://ideone.com/I0guYW


#include <iostream>
#include <cstdio>
using namespace std;

int main() {
    int n, a[]={4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777}, flag=0;
    scanf("%d", &n);
    for(int i=0; i<sizeof(a)/sizeof(a[0]); i++) if(n%a[i]==0) {flag=1; break;}
    if(flag==1) printf("YES");
    else printf("NO");
    return 0;
}

size/length of array C++:

1 - http://stackoverflow.com/questions/4108313/how-do-i-find-the-length-of-an-array

2 - http://stackoverflow.com/questions/2037736/finding-size-of-int-array

3 - http://stackoverflow.com/questions/1975128/sizeof-an-array-in-the-c-programming-language/1975133#1975133

note: array-type is implicitly converted into a pointer when passed into function other than main().

No comments:

Post a Comment