Little Jhool and Brute Force
Practice
3.1 (12 votes)
Approved
Basic programming
Brute Force search
Easy
Open
Problem
78% Success 5418 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Little Syed loves brute force. He thinks that brute force can be the solution to any problem in the world. You give him any question, and he'll have a brute force answer ready for you, almost all the time. His good friend Little Jhool (Like, always!) decides to teach him a lesson, by giving him problems which cannot be solved by brute force, because he wants Syed to learn algorithms.

  • Given a number, n, Syed needs to find the number closest to n, though less than n which satisfies Jhool's swinging theorem.

Jhool's swinging Theorem: A number n, such that it can be expressed as a sum of two positive algebraic cubes; AND, if that number can be expressed in such a manner in more than one way - it satisfies the theorem.

Now, everyone here on HackerEarth knows how much we hate Little Jhool (No, not really!) - so we want you to help Syed in figuring out Jhool's queries - once and for all!

Input Format:
The first line contains an integer, t - denoting the number of test cases.

The next t lines will contain, an integer - n - denoting the number which Jhool gives.

Output Format:
You have to print the previous number satisfying the given constraints. If no such previous number exists, print -1.

Constraints:
1 <= t <= 100
1 <= n <= 704977

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
15 votes
Tags:
AlgorithmsEasyHash MapsSorting
Points:20
9 votes
Tags:
Basic ProgrammingBasics of ImplementationEasyImplementationString Manipulation
Points:20
9 votes
Tags:
Basic ProgrammingBasics of ImplementationEasyImplementationJavaPythonQuick SortSorting