146A Codeforces - Lucky Ticket


146A Codeforces - Lucky Ticket




Solution in c++

#include <bits/stdc++.h>
using namespace std;
int sz,h1,h2;
string inp;

int main()
{
    if(4==7)
    {
        en:
            cout<<"NO";
            return 0;
    }
    cin>>sz>>inp;
    for(int i=0;i<sz;i++)
    {
        if(inp[i]!='4' && inp[i]!='7')goto en;
        if(i<sz/2)h1+=inp[i];
        else h2+=inp[i];
    }
    if(h1!=h2)goto en;
    cout<<"YES";
    return 0;
}

Share on Google Plus

About Mohamed Sobhi

My name is Mo.Sobhy ,I study at School excelling high school in Ain Shams ,Cairo
My hobbies is programming ,and web development ,playing chess and writing horror stories.
    Blogger Comment
    Facebook Comment

0 التعليقات:

إرسال تعليق