Rectangles In NxN Board
You are given a positive integer N. Your task is to find the number of possible rectangles, excluding squares, in a N x N chessboard.
Example:
Let’s assume that we have a chessboard of dimension 4x4, i.e. N = 4. Then the rectangles can have the following possible dimensions: {1*2, 1*3, 1*4, 2*1, ……, 2*4, ………,4*4}. So, the total number of rectangles in the chessboard is 70.
Input format:
The very first line of input contains an integer T’ denoting the number of test cases.
The first line of every test case contains an integer ‘N’ denoting the dimension of the chessboard.
Output format:
For each test case, print the number of possible rectangles, excluding squares, in a N x N chessboard.
Output for each test case is printed on a separate line.
Note:
The result can be very large. So, print the answer modulo 1000000007.
You do not need to print anything, it has already been taken care of. Just return the number of possible rectangles.
Constraints:
1 <= T <= 10
1 <= N <= 5 * 10^4
Time Limit: 1 sec
CodingNinjas
author
2y
Using Basic Maths
- A simple approach to solve this problem is to find the total number of possible rectangles, including squares, and then subtract the number of possible squares.
- We can easily determine...read more
Help your peers!
Add answer anonymously...
Top JPMorgan Chase & Co. Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
Top HR questions asked in JPMorgan Chase & Co. Software Developer Intern
>
JPMorgan Chase & Co. Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app