```html
The Easy Problem requires finding the number of ways to represent a given
number
'n' as a sum of two
positive integers. Here are two approaches:
Approach 1: Brute Force - Use
nested loops to iterate
through all possible pairs of positive integers
(i, j) such that
i + j = n. Count the
number of
valid pairs
and print the result.
Approach 2: Mathematical Optimization - Since the problem involves finding the
number of
ways to represent
'n'
as a sum of two positive integers, we can directly
calculate the
result as
n - 1. This is because
for any number
'n',
there are exactly
n - 1
pairs of positive
integers that sum up to
'n'.
def main(): t = int(input()) for _ in range(t): n = int(input()) cnt = 0 for i in range(1, 101): for j in range(1, 101): if i + j == n: cnt += 1 print(cnt) if __name__ == "__main__": main()
def main(): t = int(input()) for _ in range(t): n = int(input()) print(n - 1) if __name__ == "__main__": main()
Approach 1 uses nested loops, resulting in quadratic time complexity, while Approach 2 calculates the result in constant time.
Both approaches use constant extra space, making them highly efficient.