#2989. [Usaco2007 Demo]Ant Counting
[Usaco2007 Demo]Ant Counting
Description
有一天,贝茜无聊地坐在蚂蚁洞前看蚂蚁们进进出出地搬运食物.很快贝茜发现有些蚂蚁长得几乎一模一样,于是她认为那些蚂蚁是兄弟,也就是说它们是同一个家族里的成员.她也发现整个蚂蚁群里有时只有一只出来觅食,有时是几只,有时干脆整个蚁群一起出来.这样一来,蚂蚁们出行觅食时的组队方案就有很多种.作为一头有数学头脑的奶牛,贝茜注意到整个蚂蚁群由T(1≤T≤1000)个家族组成,她将这些家族按1到T依次编号.编号为i的家族里有Ni(1≤Ni≤100)只蚂蚁.同一个家族里的蚂蚁可以认为是完全相同的.
·1只蚂蚁出去有三种组合:(1)(2)(3)
·2只蚂蚁出去有五种组合:(1,1)(1,2)(1,3)(2,2)(2,3)
·3只蚂蚁出去有五种组合:(1,1,2)(1,1,3)(1,2,2)(1,2,3)(2,2,3)
·4只蚂蚁出去有三种组合:(1,2,2,3)(1,1,2,2)(1,1,2,3)
·5只蚂蚁出去有一种组合:(1,1,2,2,3)
Format
Input
- Line 1: 4 space-separated integers: T, A, S, and B
- Lines 2..A+1: Each line contains a single integer that is an ant type present in the hive
Output
- Line 1: The number of sets of size S..B (inclusive) that can be created. A set like {1,2} is the same as the set {2,1} and should not be double-counted. Print only the LAST SIX DIGITS of this number, with no leading zeroes or spaces.
Samples
Limitation
INPUT DETAILS:
Three types of ants (1..3); 5 ants altogether. How many sets of size 2 or size 3 can be made?
OUTPUT DETAILS:
5 sets of ants with two members; 5 more sets of ants with three members