bzoj#P2274. [Usaco2011 Feb]Generic Cow Protests
[Usaco2011 Feb]Generic Cow Protests
题目描述
Farmer John's cows are lined up in a row and numbered .The cows are conducting another one of their strange protests,so each cow is holding up a sign with an integer .
FJ knows the mob of cows will behave if they are properly grouped and thus would like to arrange the cows into one or more contiguous groups so that every cow is in exactly one group and that every group has a nonnegative sum.
Help him count the number of ways he can do this,modulo .
By way of example,if and the cows' signs are ,and ,then the following are the only four valid ways of arranging the cows:
( )
( ) ()
() ( )
() ( ) ()
Note that this example demonstrates the rule for counting different orders of the arrangements.
给出 个数,问有几种划分方案(不能改变数的位置),使得每组中数的和大于等于 。输出方案数除以 的余数。
输入格式
-
Line :A single integer:
-
Lines :Line contains a single integer:
输出格式
- Line :A single integer,the number of arrangements modulo .
4
2
3
-3
1
4
题目来源
Gold
数据规模与约定
的数据满足:,。