题目链接:
Kyoya Ootori has a bag with n colored balls that are colored with k different colors. The colors are labeled from 1 to k. Balls of the same color are indistinguishable. He draws balls from the bag one by one until the bag is empty. He noticed that he drew the last ball of color ibefore drawing the last ball of color i + 1 for all i from 1 to k - 1. Now he wonders how many different ways this can happen.
The first line of input will have one integer k (1 ≤ k ≤ 1000) the number of colors.
Then, k lines will follow. The i-th line will contain ci, the number of balls of the i-th color (1 ≤ ci ≤ 1000).
The total number of balls doesn't exceed 1000.
A single integer, the number of ways that Kyoya can draw the balls from the bag as described in the statement, modulo 1 000 000 007.
3 2 2 1
3
4 1 2 3 4
1680 题意: k种颜色的求,第i种颜色的球有a[i]个,现在要求第i种球的最后一个一定在第i+1种球的最后一个的前边,问有多少种拿法; 思路: dp[i]表示前i种球的拿法的方案数,再拿第i+1种球的时候,先取出一个放在最后,然后剩下a[i+1]-1个球,前边有sum个球,形成sum+1个空挡,相当于把a[i+1]-1个相同的小球放在sum+1个不同的盒子中,看这里总结的; AC代码:
#include#include #include #include #include #include #include #include