Saturday, June 28, 2014

Codeforces Beta Round #84 (Div. 2 Only), problem: (A) Nearly Lucky Number solution

Codeforces Beta Round #84 (Div. 2 Only), problem: (A) Nearly Lucky Number: http://codeforces.com/problemset/problem/110/A

Codeforces Beta Round #84 (Div. 2 Only), problem: (A) Nearly Lucky Number editorial: http://codeforces.com/blog/entry/2547

Codeforces Beta Round #84 (Div. 2 Only), problem: (A) Nearly Lucky Number solution: http://ideone.com/xkzcsK


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

int main() {
    int cnt=0, a=0, r=0, p=0;
    char s[25];
    scanf("%s", s);
    for(int i=0; i<strlen(s); i++) if(s[i]=='4' || s[i]=='7') cnt++;
    while(cnt>0) {
        a=cnt%10;
        cnt/=10;
        p++;
        if(a==4 || a==7) r++;
    }
    if(r==p && r>0) printf("YES");
    else printf("NO");
    return 0;
}

No comments:

Post a Comment