Thursday, February 5, 2015

Solution of 110A. Nearly Lucky Number (Codeforces)

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
typedef long long ll;

int main()
{
    string s;
    cin >> s;
    ll len = s.length();
    ll count =0;
    for(int i=0; i<len; i++)
    {
        if(s[i]=='7' || s[i]=='4')
        {
            count++;
        }
    }
    if(count == 4 || count == 7)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

}

2 comments:

  1. this is not the correct solution buddy!
    #include
    #include
    #include
    #include
    using namespace std;
    typedef long long ll;

    int main()
    {
    string s;
    cin >> s;
    ll len = s.length();
    ll count =0;
    for(int i=0; i<len; i++)
    {
    if(s[i]=='7' || s[i]=='4')
    {
    count++;
    }
    }
    if(count == s.length())
    {
    cout << "YES" << endl;
    }
    else
    {
    cout << "NO" << endl;
    }

    }

    ReplyDelete

Compare equality of two string in C

#include <stdio.h> #include<string.h> int main() {     char* country = "Bangladesh";     char* country2;     ...