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 #218: Perfect right-angled triangles

Project Euler #218: Perfect right-angled triangles

Problem
Submissions
Leaderboard
Discussions

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

Consider the right angled triangle with sides , and . The area of this triangle is , which is divisible by the perfect numbers and .
Moreover it is a primitive right angled triangle as and .
Also is a perfect square.

We will call a right angled triangle perfect if

  • it is a primitive right angled triangle
  • its hypotenuse is a perfect square

We will call a right angled triangle super-perfect if

  • it is a perfect right angled triangle and
  • its area is a multiple of the perfect numbers and .

How many perfect right-angled triangles with exist that are not super-perfect?

Input Format

First line of each test file contains a single integer that is the number of queries. lines follow, each containing an integer - an upper bound of the largest side of the triangle.

Constraints

Output Format

Print exactly lines with a single integer on each: an answer to the corresponding query.

Sample Input 0

1
25

Sample Output 0

0

Explanation 0

As we can see from the problem statement, the only perfect triangle with is super-perfect.

Author

bayleef

Difficulty

Easy

Max Score

100

Submitted By

5534

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