Sad Splits Solution || Codechef March Lunchtime 2022

        

Sad Splits Solution 

Codechef March Lunchtime 2022
Problem Code : SPLITPAIR

Solution :

#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
using namespace std;

void solve()
{
    ll n;
    cin >> n;
    if (n % 2 == 0)
    {
        ll odd = 0, even = 0;
        while (n)
        {
            if ((n % 10) % 2)
            {
                odd++;
            }
            else
            {
                even++;
            }
            n /= 10;
        }
        if (even >= 2)
        {
            cout << "YES\n";
        }
        else
        {
            cout << "NO\n";
        }
    }
    else
    {
        ll odd = 0, even = 0;
        while (n)
        {
            if ((n % 10) % 2)
            {
                odd++;
            }
            else
            {
                even++;
            }
            n /= 10;
        }
        if (odd >= 2)
        {
            cout << "YES\n";
        }
        else
        {
            cout << "NO\n";
        }
    }
}

int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        solve();
    }
}

Comments