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 #94: Almost equilateral triangles

Project Euler #94: Almost equilateral triangles

Problem
Submissions
Leaderboard
Discussions

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

It is easily proved that no equilateral triangle exists with integral length sides and integral area. However, the almost equilateral triangle has an area of square units.

We shall define an almost equilateral triangle to be a triangle for which two sides are equal and the third differs by no more than one unit.

Find the sum of the perimeters of all almost equilateral triangles with integral side lengths and area and whose perimeters do not exceed .

Input Format

First line contains , denoting the number of testcases.
Next lines contains .

Constraints


Output Format

Output lines corresponding to test cases.

Sample Input

2
17
51

Sample Output

16
66

Explanation

For first test case we get perimeter .
Second test case there is another triangle whose area is units.

Author

shashank21j

Difficulty

Medium

Max Score

100

Submitted By

848

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