DCP-307: Count the Ways Back to All Problems

Medium Math > Combinations and Permutations

**Petr** and some of his friends went to a shop to buy some balls. They are **N** people. There are actually **N** different colors of ball. The number of balls of ith color is **Ci**. Now Petr wants to know in how many ways they can buy all balls of the shop so that, everyone have at least one ball of all different color. You have to find the answer modulo **1000000007**. Input: ------ Input starts with an integer **T** (1<=T<=100) denoting the number of test cases. Each case starts with a positive integer N (1<=N<=1000), denoting the number of people and the number of color. In the next line there are **N** integers ( Ci ) denoting the number of balls of ith color ( 0<=Ci<=2000). Output: ------- Output T lines, with case number at the beginning and then the answer. See sample input output for more details. Sample Input ------------ 2 3 3 3 3 2 3 2 Sample Output ------------- Case 1: 1 Case 2: 2

Problem Setter:

Al Mamun Akash

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 2.00
C++ 2.00
C++14 2.00
C# 2.00
Go 2.00
Java 3.00
JavaScript 2.00
Objective-C 2.00
Perl 2.00
PHP 2.00
Python 2.00
Python3 2.00
Ruby 2.00
VB.Net 2.00

Problem Stats




# User Language Timing
01 farhanhasin Cpp 0.02s
02 Rajib_119 Cpp 0.02s
03 Robbinb1993 Cpp 0.03s
04 Zeronfinity Cpp 0.03s
05 khatribiru Cpp 0.04s
06 zyyxxx Cpp 0.04s
07 sayedgkm Cpp14 0.04s
08 JACKAL1586 Cpp14 0.04s
09 feodorv C 0.04s
10 dipta007 Cpp 0.05s
11 imranziad Cpp 0.06s
12 Superstorm Cpp14 0.06s
13 tariqiitju Cpp14 0.07s
14 njrafi Cpp 0.07s
15 I_See_You Cpp14 0.08s
16 Double_O Cpp 0.08s
17 sahedsohel Cpp 0.09s
18 mahbubcseju Cpp 0.09s
19 robincse14 Cpp 0.11s
20 PKP_007 Cpp 0.12s
21 fsshakkhor Cpp14 0.12s
22 sifat_15 Cpp 0.12s
23 by_default Cpp 0.13s
24 kitorp Cpp14 0.15s

Your feedback is our precious!

Or call +88 02 9853138 for support