4026. partition problem

Naive循环数组

时间限制:2000 ms

内存限制:512 MiB

题面

Given a set of numbers, the partition problem is to find a subset of the numbers that add up to a specific target number. For example, there are two ways to partition the set {1,3,4,5}\lbrace 1, 3, 4, 5\rbrace so that the remaining elements add up to 55:

  1. Select the 11 and the 44
  2. Select just the 55

By contrast, there is no way to partition the set {1,3,4,5}\lbrace 1, 3, 4, 5\rbrace to get 1111.

Write a program that enters a target number, and then several integers as elements of the set, and print number of partitions.

For example, print 22 if 5,1,3,4,55,1,3,4,5 are entered (all integers are separated by a blank), and print 00 if 11,1,3,4,511,1,3,4,5 are entered.

样例

输入

5 1 3 4 5

输出

2

输入

11 1 3 4 5

输出

0