Pku1837 Balance

时间限制:5s      空间限制:64MB

题目描述

Gigel has a strange "balance" and he wants to poise it. Actually, the device is different from any other ordinary balance. It orders two arms of negligible weight and each arm's length is 15. Some hooks are attached to these arms and Gigel wants to hang up some weights from his collection of G weights (1 <= g="" <="20)" knowing="" that="" these="" weights="" have="" distinct="" values="" in="" the="" range="" 1..25.="" gigel="" may="" droop="" any="" weight="" of="" hook="" but="" he="" is="" forced="" to="" use="" all="" weights.="" finally,="" managed="" balance="" device="" using="" experience="" gained="" at="" national="" olympiad="" informatics.="" now="" would="" like="" know="" how="" many="" ways="" can="" be="" balanced.="" repartition="" hooks="" and="" set="" write="" a="" program="" calculates="" number="" possibilities="" device.="" it="" guaranteed="" will="" exist="" least="" one="" solution="" for="" each="" test="" case="" evaluation.="" 输入一个天平若干(<="20)挂钩的位置,将若干(<=20)砝码挂到天平上,问有多少种使天平挂平衡的方法。" p="">


输入格式

The input has the following structure: • the first line contains the number C (2 <= c="" <="20)" and="" the="" number="" g="" (2="" •="" next="" line="" contains="" integer="" numbers="" (these="" are="" also="" distinct="" sorted="" in="" ascending="" order)="" range="" -15..15="" representing="" repartition="" of="" hooks;="" each="" represents="" position="" relative="" to="" center="" balance="" on="" x="" axis="" (when="" no="" weights="" attached="" device="" is="" balanced="" lined="" up="" axis;="" absolute="" value="" distances="" distance="" between="" hook="" sign="" determines="" arm="" which="" attached:="" '-'="" for="" left="" '+'="" right="" arm);="" there="" natural,="" order="" 1..25="" weights'="" values.="" p="">


输出格式

The output contains the number M representing the number of possibilities to poise the balance.


样例输入

2 4	
-2 3 
3 4 5 8

样例输出

2

提示

第一种放法把(4,8)放左边,(3,5)放右边 第二种放法把((3,4,5)放左边,8单独放右边


题目来源

没有写明来源

Menuappsclose