The Triangles, Mason !
All submissions for this problem are available.
Jason has given Mason a puzzle. Puzzle is
There is a n x m grid of square shaped
cells. Here is single cell of grid ::
Mason has to tell how many triangles of any
size are there in this grid. Since Mason is a little weak with logic, he has
asked you for the answer.
First line contains a single integer T,
number of test cases.
Each test begins with a single line containing 2 space separated integers:n
and m, the no. of rows and no. of columns in the grid.
For every test case, output a single
integer: the total no. of triangles of any size in the grid.
Output the answer modulo 1000000007 (109+7).
2 1 1 2 3Output:
First Test Case: For 1x1 grid there will be 2 triangles, as shown below:
Second Test Case: For 2x3 grid there will
be 12 small triangles and 4 large triangles. 4 large triangles are shown below:
|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