#9367. [USACO12OPEN] Balanced Cow Subsets G

    ID: 9367 传统题 1000ms 125MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>P3067搜索2012USACO折半搜索 meet in the middle

[USACO12OPEN] Balanced Cow Subsets G

[USACO12OPEN] Balanced Cow Subsets G

题目描述

Farmer John's owns N cows (2 <= N <= 20), where cow i produces M(i) units of milk each day (1 <= M(i)

Let us call a subset of cows "balanced" if it can be partitioned into two groups having equal milk output. Since only a balanced subset of cows can make the milking machine work, FJ wonders how many subsets of his N cows are balanced. Please help him compute this quantity.

输入格式

\* Line 1: The integer N.

* Lines 2..1+N: Line i+1 contains M(i).

输出格式

\* Line 1: The number of balanced subsets of cows.
4 
1 
2 
3 
4 
3 

提示

There are 4 cows, with milk outputs 1, 2, 3, and 4.

There are three balanced subsets: the subset {1,2,3}, which can be partitioned into {1,2} and {3}, the subset {1,3,4}, which can be partitioned into {1,3} and {4}, and the subset {1,2,3,4} which can be partitioned into {1,4} and {2,3}. 标签: P3067|搜索|2012|USACO|折半搜索 meet in the middle

来源

P3067|[USACO12OPEN] Balanced Cow Subsets G