We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #85: Counting rectangles

Project Euler #85: Counting rectangles

Problem
Submissions
Leaderboard
Discussions

This problem is a programming version of Problem 85 from projecteuler.net

By counting carefully it can be seen that a rectangular grid measuring 3 by 2 contains eighteen rectangles:

For each testcase an integer target would be given . Consider all the rectangular grids such that the number of rectangles contained in the grid is nearest to target . Out of all such rectangular grids output the area of the rectangular grid having the largest area.

Input Format

First line contains denoting the number of testcases.
The following lines contain an integer .

Constraints


Output Format

For each testcase print the area of the desired rectangular grid .

Sample Input

2
18
2

Sample Output

6
2

Explanation

Case1: A grid contains 18 rectangles.

Case2:

is 2 . The grid contains rectangle and the grids and contain rectangles each.

All other rectangular grids contain more than rectangles.

Hence The set of grids containing the number of rectangles nearest to are , , .

Out of these and are the grids having the largest area equal to .

Hence is the answer as it is the largest area in the set of rectangular grids being considered.

Author

shashank21j

Difficulty

Medium

Max Score

100

Submitted By

1545

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy