S01E01 - Editorial

PROBLEM LINK:

Contest Division 3

Setter: Kanhaiya Mohan
Tester: Nishant Shah
Editorialist: Shubham Sharma

DIFFICULTY

Cakewalk

PREREQUISITES

Basic mathematics/reasoning

PROBLEM

Given a number N. You need to write N as a sum of 6 positive numbers such that each number is unique.

EXPLANATION

Observation: N must be greater than or equal to 21 for satisfying the given condition.

Proof

Let’s take our numbers to be as small as possible. The first 6 unique positive numbers are 1, 2, 3, 4, 5, 6. For them N = 1 + 2 + 3 + 4 + 5 + 6 = 21.

For N >= 21, N can always be written as 1 + 2 + 3 + 4 + 5 + X, where X is N - (1 + 2 + 3 + 4 + 5).

For N < 21, N can not be written as a sum of 6 positive numbers such that each number is unique.

CONCLUSION

If we have N equal to or greater than 21, then it is always N as per given conditions. So, the answer is ‘YES’.
Else the answer is ‘NO’.

SOLUTIONS

Setter's Solution
#include <bits/stdc++.h>
using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);


    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        if(n >= 21){
            cout << "YES\n";
        }
        else{
            cout << "NO\n";
        }
    }


    return 0;
}