PAINTBLC - Painting Blocks (Act II) no tags n blocks are put in a line. You have…
- User
PAINTBLC - Painting Blocks (Act II) no tags
n blocks are put in a line. You have k(1<=k<=15) kinds of dope, the i-th dope is enough to paint ci (1<=ci<=6) blocks. You may assume the sum of all the ci equals to n. Your task is to calculate the number of ways to paint the blocks with these kinds of dope, such that no two adjacent blocks are painted with the same kind of dope.
Input Input consists of multiple test cases, the number of them (<=2000) is given in the very first line. For each test case, the first line contains an integer k, the second line contains k integers, c1, c2, ...ck.
Output For each test case, output one line with an integer, the number of ways modulo 1000000007.
Example Input: 3 3 1 2 3 5 2 2 2 2 2 10 1 1 2 2 3 3 4 4 5 5
Output: 10 39480 85937576 solve in c++ use dp use something like dp(i, j) = sum (dp(i - 1, j - x) - dp(i - 1, j - 2x)) where i is number of used types x is last taken j is the sum and then go through all i for j = sum and sum them up or something like this
- Assistant
- User
||=== Build: Release in 1 (compiler: GNU GCC Compiler) ===| C:\Users\USER\OneDrive\Desktop\c++\1\main.cpp||In function 'int main()':| C:\Users\USER\OneDrive\Desktop\c++\1\main.cpp|46|error: expected ';' before ')' token| ||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
- Assistant
- User
polish the dp idea
- Assistant