Codeforces Nearly Lucky Number

#include<bits/stdc++.h>
using namespace std;

typedef long long LL;

int main()
{
    ios_base::sync_with_stdio(false);

    LL n;
    while(cin >> n)
    {
        LL cnt=0;

        while(n)
        {
            if(n%10 == 4 or n%10==7) cnt++;
            n/=10;
        }

        if(cnt==4 or cnt==7 or cnt==47 or cnt==744) cout << "YES\n";
        else cout << "NO\n";
    }

    return 0;
}

Comments

Popular posts from this blog

SPOJ-CMG - Collecting Mango

LightOJ 1009 - Back to Underworld

LeetCode Palindrome Number