GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Thursday 22 September 2022

[Solution] Integers that sum to the same value CodeChef Solution



Problem

Alice has a positive integer N. She is wondering how many ordered pairs of positive integers (i, j) exist such that i + j = N.

Help Alice figure out the answer.

Note that since the pairs are ordered, (1, 2) and (2, 1) are considered different.

Input Format

The first and only line of input contains a single integer N.

Output Format

Print a single integer, the number of ordered pairs of positive integers (i, j) such that i + j = N.


Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

Explanation:

As both integers must be positive, the minimum sum must be 1 + 1 = 2. Therefore there are no pairs of positive integers adding up to 1.

Explanation:

(1,1) is the only pair whose sum is 2. Every other pair has a sum of at least 3.

Explanation:

The two pairs are (1, 2) and (2, 1).

No comments:

Post a Comment