πŸ“˜ Day 7 – Teacher's Day Challenge | Watermelon Division Logic

TanishiTanishi
2 min read

πŸ—“οΈ Date: July 31, 2025
πŸ”’ Problems Solved Today: 1
🎯 Focus Topic: Conditional Logic, Input/Output, Edge Cases

πŸ’» Platform: Codeforces


πŸ”— Table of Contents


🧩 Problem 1 – Watermelon

πŸ”— Codeforces Problem – Watermelon #4A
πŸ“š Difficulty: Easy
🧠 Concepts: Even/Odd Numbers, Conditionals, Edge Case Handling


πŸ“„ Problem Statement (Summary):
Given a watermelon of weight w (1 ≀ w ≀ 100), determine if it can be split into two parts, both with even positive weights (not necessarily equal). Print "YES" or "NO".


πŸ’‘ Approach:

  • Input the weight w.

  • Check two conditions:

    • w should be greater than 2 (to avoid cases like 1 or 2 which can’t be split into two even parts).

    • w should be even (since even + even = even).

  • If both conditions are true, print "YES"; else, print "NO".


πŸ§ͺ Code (C++):

#include<iostream>
using namespace std;
int main(){
    int w;
    cin >> w;
    if(w > 2 && w % 2 == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

πŸ“Έ Submission Screenshot:


βœ… Key Takeaways:

  • Always handle edge cases like smallest numbers (1 and 2).

  • Use % operator for evenness check.

  • w > 2 is critical since 2 is even but not splittable into two positive even parts.

  • Simple if-else logic is enough for many Codeforces problems.


πŸ“ˆ Daily Summary

MetricValue
Problems Solved1
Topics CoveredConditionals, Edge Case Checking
Tools UsedC++
Next FocusGreedy, Math, Arrays
Day7 / 30

🏷️ Tags:
#codeforces #conditionals #cpp #evennumbers #logicbuilding #edgecases #43DaysChallenge

0
Subscribe to my newsletter

Read articles from Tanishi directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Tanishi
Tanishi