553A.md (1365B)
1 Source: https://codeforces.com/problemset/problem/553/A 2 3 A. Kyoya and Colored Balls 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 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 *i* before 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. 22 23 Input 24 25 The first line of input will have one integer *k* (1 ≤ *k* ≤ 1000) the number of colors. 26 27 Then, *k* lines will follow. The *i*-th line will contain *c**i*, the number of balls of the *i*-th color (1 ≤ *c**i* ≤ 1000). 28 29 The total number of balls doesn't exceed 1000. 30 31 Output 32 33 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. 34 35 Examples 36 37 Input 38 39 ``` 40 3 41 2 42 2 43 1 44 ``` 45 46 Output 47 48 ``` 49 3 50 ``` 51 52 Input 53 54 ``` 55 4 56 1 57 2 58 3 59 4 60 ``` 61 62 Output 63 64 ``` 65 1680 66 ``` 67 68 Note 69 70 In the first sample, we have 2 balls of color 1, 2 balls of color 2, and 1 ball of color 3. The three ways for Kyoya are: 71 72 ``` 73 1 2 1 2 3 74 1 1 2 2 3 75 2 1 1 2 3 76 ```