HBC24618数字计数,语言题[USACO 2011 Feb G]Generic Cow Protest题解

北笙凉宸 算法基础篇 40 0
想要成为编程高手?那就来试试全网最全C++题库,让您在练习中快速成长。
Farmer John's N (1

Farmer John's N (1 <= N <= 100,000) cows are lined up in a row and numbered 1..N. The cows are conducting another one of their strange protests, so each cow i is holding up a sign with an integer A_i A i ​ (-10,000 <= A_i A i ​ <= 10,000). 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 1,000,000,009. By way of example, if N = 4 and the cows' signs are 2, 3, -3, and 1, then the following are the only four valid ways of arranging the cows: (2 3 -3 1) (2 3 -3) (1) (2) (3 -3 1) (2) (3 -3) (1) Note that this example demonstrates the rule for counting different orders of the arrangements.

HBC24618数字计数,语言题[USACO 2011 Feb G]Generic Cow Protest题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
成为编程大师,不再是梦想!全网最全C++题库,助您开启编程新篇章。

标签: HBC24618数字计数 语言题[USACO 2011 Feb G]Generic Cow Protest题解