For many sets of consecutive integers from to , it is possible to partition the set into two subsets with equal sums.
For example, if n = 3, one can partition the set \{ 1, 2, 3 \} in only one way so that the sums of both subsets are equal:
and
This is counted as a single partition (partitioning with subsets swapped is considered the same and does not increase the count).
If n = 7, there are four ways to partition the set \{1, 2, 3, \ldots, 7\} into two subsets with equal sums:
\{1, 6, 7\} and \{2, 3, 4, 5\}
\{2, 5, 7\} and \{1, 3, 4, 6\}
\{3, 4, 7\} and \{1, 2, 5, 6\}
\{1, 2, 4, 7\} and \{3, 5, 6\}
Given , determine the number of ways the set \{1, 2, \ldots, n\} can be partitioned into two subsets with equal sums. If no such partition exists, print 0.
One integer (1 \leq n \leq 39).
Print the number of possible partitions of \{1, 2, \ldots, n\} into two subsets with equal sums. Print 0 if no such partition exists.
Example 1