#C1487. Consecutive Positive Integer Sums
Consecutive Positive Integer Sums
Consecutive Positive Integer Sums
Given a positive integer \(N\), determine the number of ways to express \(N\) as a sum of two or more consecutive positive integers.
In other words, you need to find the number of sequences \(a, a+1, a+2, \ldots, a+k\) (with \(k \ge 1\)) such that:
[ N = a + (a+1) + \cdots + (a+k) \quad \text{with} \quad a \ge 1, ]
Note that the sequence must contain at least two integers. For example, when \(N = 15\), there are 3 valid representations:
- \(7 + 8 = 15\)
- \(4 + 5 + 6 = 15\)
- \(1 + 2 + 3 + 4 + 5 = 15\)
Your task is to compute this number for several test cases.
inputFormat
The input is read from standard input and has the following format:
T N1 N2 ... NT
Here, \(T\) is the number of test cases, and each \(N_i\) is a positive integer.
outputFormat
For each test case, output one integer on a new line representing the number of ways to express \(N\) as a sum of two or more consecutive positive integers.
## sample5
15
10
1
5
9
3
1
0
1
2
</p>