All submissions for this problem are available.
You are given N boxes with label 1,2,3,...., N and three colours 'R', 'B' and 'G' and each colour have some consecutively coloring limit means you can consecutively color boxes with one color not more than its given limit. You have to paint the boxes using given colour. Now your task is to find the total number of ways to paint the boxes. The answer can be very large so you have to print answer modulo 1e9 +7.
For example, suppose you are given 3 boxes and colours limit 1, 1, 1.
So all possible colouring of boxes will be as follows:
R B R
R G R
B R B
B G B
G R G
G B G
R B G
R G B
B G R
B R G
G B R
G R B
So in above example, we can see that there are 12 ways to paint the boxes.
The first line contains an integer T, denoting the number of test cases.
The first line of each test case contains an integer N, denoting the number of boxes.
The second line of each test case contains three integer R, G, and B, denoting the limit of each colour.
For every test case print the total ways in new line.
Constraints and Subtasks
Subtask 1: 5 points
Input: 1 3 1 1 1 Output: 12
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions