π Day 7 β Teacher's Day Challenge | Watermelon Division Logic


ποΈ Date: July 31, 2025
π’ Problems Solved Today: 1
π― Focus Topic: Conditional Logic, Input/Output, Edge Cases
π» Platform: Codeforces
π Table of Contents
Daily Summary
π§© 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 since2
is even but not splittable into two positive even parts.Simple
if-else
logic is enough for many Codeforces problems.
π Daily Summary
Metric | Value |
Problems Solved | 1 |
Topics Covered | Conditionals, Edge Case Checking |
Tools Used | C++ |
Next Focus | Greedy, Math, Arrays |
Day | 7 / 30 |
π·οΈ Tags:#codeforces #conditionals #cpp #evennumbers #logicbuilding #edgecases #43DaysChallenge
Subscribe to my newsletter
Read articles from Tanishi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
