DEV Community

Thivyaa Mohan
Thivyaa Mohan

Posted on

122 A - Lucky Division| Codeforces Lucky Division Solution| A2oj Ladders Div 2A.

Petya considers the numbers which has 4 and 7 as lucky numbers.
Considering all the permutations we get 12 different numbers.

These are the 12 different permutations of numbers.
4,7,47,74,44,444,447,474,477,777,774,744

Petya also considers its almost lucky if it is divisible by some lucky number.

#include <stdio.h>
#include <iostream>
using namespace std;

int main()
{
        int lucky_numbers[] = {4,7,47,74,44,444,447,474,477,777,774,744};
        int n, count =0;
        cin>>n;
        for(int i =0;i<12;i++)
        {
            if(n%lucky_numbers[i] == 0) count++;

        }
        if(count>0) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
        return 0;

}
Enter fullscreen mode Exit fullscreen mode

Hope this helps!
Happy Coding

Top comments (0)