Coloring in HypercubeProblem code: HPARITY |
All submissions for this problem are available.
In an N-dimensional grid the co-ordinates of a cell are denoted as X1, X2, ..., XN. Any cell with negative co-ordinate are colored white. The origin cell (the one with all zero co-ordinates) is colored as black. The color of a cell in (X1, X2, ..., XN) depends on the N cells with co-ordinates (X1-1, X2, ..., XN), (X1, X2-1, ..., XN), ...., (X1, X2, ..., XN-1). The cell is colored white if and only if the number of black colored cells among these N co-ordinates are even, otherwise the cell is colored black.
You are given the starting and ending co-ordinate of sub-hypercube. You need to compute how many hyper cells in this sub hypercube are colored black.
Input
First line of the input contains T the number of test cases. Each test case starts with a line containing N the dimension of the hypercube. The second line contains N integers denoting the co-ordinate of the starting cell of the hypercube. The third line contains N integers denoting the co-ordinate of the ending cell of the hypercube.
Output
For each test case, output the number of black colored cells in the given hypercube. Since the result can be too big so output the result modulo 1000000009.
Example
Input
3 3 4 0 4 7 9 8 2 0 3 10 9 4 0 3 0 2 6 8 1 5Output:
9 32 22Constraints
T < 51 0 < N < 9
All the co-ordinates will be non negative integers with at most 15 digits.
| Date: | 2011-06-06 |
| Time limit: | 4s |
| Source limit: | 50000B |
| Languages: | All |
Comments
Loading Comments...
SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:
Loading Submissions...RECENT ACTIVITY FOR THIS PROBLEM:
Loading Recent Activity...HELP
Program should read from standard input and write to standard output.
After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:
- Accepted
Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark. - Time Limit Exceeded
Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach. - Wrong Answer
Your program compiled and ran succesfully but the output did not match the expected output. - Runtime Error
Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section. - Compilation Error
Your code was unable to compile. When you see this icon, click on it for more information.
If you are still having problems, see a sample solution here.
