[Solution] Bags with Balls Codeforces Solution
There are bags, each bag contains balls with numbers from to . For every , there is exactly one ball with number in each bag.
You have to take exactly one ball from each bag (all bags are different, so, for example, taking the ball from the first bag and the ball from the second bag is not the same as taking the ball from the first bag and the ball from the second bag). After that, you calculate the number of balls
occupied
with odd numbers among the ones you have taken. Let the number of these balls be .
Your task is to calculate the sum of over all possible ways to take balls, one from each bag.
The first line contains one integer () — the number of test cases.
Each test case consists of one line containing three integers , and (; ).
For each test case, print one integer — the sum of over all possible ways to take balls, one from each bag. Since it can be huge, print it modulo .
No comments:
Post a Comment