Rectangle Counting on an N x N Chessboard
Given a positive integer N, determine the number of possible rectangles that can be formed on an N x N chessboard, excluding squares.
Input:
The first line contains an integer T, the number of test cases.
Each of the following T lines contains a single integer N, the dimension of the chessboard.
Output:
For each test case, output the number of rectangles (excluding squares) that can be formed on the chessboard.
Example:
Input:
2
3
4
Output:
20
70
Constraints:
- 1 <= T <= 10
- 1 <= N <= 5 * 10^4
- Results should be returned modulo 1000000007.
Note:
Calculate the total number of rectangles possible and subtract the number of squares from it. Return the count modulo 1000000007 for each test case.

AnswerBot
4mo
Count the number of rectangles (excluding squares) that can be formed on an N x N chessboard.
Calculate total rectangles using formula N*(N+1)*M*(M+1)/4 where M = N-1
Subtract the number of squares (N*(...read more
Help your peers!
Add answer anonymously...
Top Software Developer Intern Interview Questions Asked at JPMorgan Chase & Co.
Q. Count Subarrays with Given XOR Problem Statement You are given an array of integ...read more
Q. Kth Largest Number Problem Statement You are given a continuous stream of number...read more
Q. Stack using Two Queues Problem Statement Develop a Stack Data Structure to store...read more
Interview Questions Asked to Software Developer Intern at Other Companies
Top Skill-Based Questions for JPMorgan Chase & Co. Software Developer Intern
C++ Interview Questions and Answers
300 Questions
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Operating Systems Interview Questions and Answers
250 Questions
System Design Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

