‹ 上一题 下一题 ›

07457. 集合 Subset Sums 未做

1000 ms 128 MB 测试点 11 动态规划好题精选外站题子集和计数÷2(USACO2.2)
外站题 · 本站已按题目要求生成完整数据包,可直接提交评测;也可去洛谷原题提交对比: 去洛谷原题提交 ↗

题目描述

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. 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 , 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.

输入格式

A single line with a single integer .

输出格式

A single line with a single integer that tells how many same-sum partitions can be made from the set . The output should be if there are no ways to make a same-sum partition.

样例

输入
7
输出
4

说明/提示

USACO Training Section 2.2.


来源:洛谷 P1466(集合 Subset Sums)。本页为题面搬运;本站数据为按题目要求自造的完整数据包,也推荐去原网站提交对比。

去原网站提交 ↗
输入
输出

            
答案