PROBLEM 55
Medium

Quarter by Month

Programming Basics · C++

</>
STATUS Not solved

TASK

Problem

#55

Given a month number `m` from 1 to 12, print its quarter number: 1 for January–March, 2 for April–June, 3 for July–September, 4 for October–December.

EXAMPLE

Example

Input
1
Output
1

LIMITS

Constraints

1 ≤ m ≤ 12.
📖
LEARN Theory for this problem
+

An `if` / `else if` / `else` chain checks alternatives from top to bottom. Put more specific or higher-priority conditions first.

Connection to “Quarter by Month”: here, intermediate values are best kept in named variables so the formula stays readable and data types remain clear.

💡
NEED HELP? Hints
+

['List the possible cases and make them mutually exclusive.', 'After solving “Quarter by Month”, verify the algorithm on your own small example and on an allowed boundary case. Print only the required result with no extra text.']

ANSWER Solution
+
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    long long n;
    cin >> n;
    cout << (n - 1) / 3 + 1;
    cout << '\n';
    return 0;
}