#Lutece0191. Subset Sums
Subset Sums
Migrated from Lutece 191 Subset Sums
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
For many sets of consecutive integers from through (), one can partition the set into two sets whose sums are identical.
For example, if , one can partition the set in one way so that the sums of both subsets are identical:
- and
This counts as a single partitioning (i.e., reversing the order counts as the same partitioning and thus does not increase the count of partitions).
If , there are four ways to partition the set so that each partition has the same sum:
- and
- and
- and
- and
Given , your program should print the number of ways a set containing the integers from through can be partitioned into two sets whose sums are identical. Print if there are no such ways.
Your program must calculate the answer, not look it up from a table.
Input
The input file contains a single line with a single integer representing , as above.
Output
The output file contains a single line with a single integer that tells how many same-sum partitions can be made from the set . The output file should contain if there are no ways to make a same-sum partition.
Samples
7
4
Resources
USACO TRAINING selected by rectaflex