Painting The logo
Tag(s):

## Algorithms, Binary search algorithm, Medium, Sorting algorithm

Problem
Editorial
Analytics

Rahul has set upon the quest for a new logo of his company. He has created the following continuous logo:

    /\
/  \
/ /\ \
/ /  \ \
/ / /\ \ \
\ \ \/ / /
\ \  / /
\ \/ /
\  /
\/


However, his sister, Rashi, likes the following discontinuous design more

   /\
/  \
/ /\ \
/ /  \ \
\ \  / /
\ \/ /
\  /
\/


The size of a logo is the longest continuous streak of same characters on an arm.

So, size of 1st logo is 5 while that of 2nd one is 4.

We know that every '/' or '\' character requires exactly 1 unit of paint.

Now, Rahul has X units of paint and would like to draw each of the two favorite logos of himself and his sister, Rashi. So, as to consume it optimally, he wants to know the maximal possible sizes of the two logos that can be drawn such that the difference in sizes of both logos is atmost 1.

Note that it is necessary to be able to draw both the logos. In case, the paint is not enough, output 0 0 instead.

Input Format:

The first line of input file contains T, the number of test cases to follow.
Each test case contains exactly 1 line containing X, the amount of paint Rahul has.

Output Format:

Print two space-separated integers, which denote sizes of Rahul's favourite logo and Rashi's favorite logo, respectively.

Constraints:

1 ≤ T ≤ 105
1 ≤ N ≤ 1015

Sample Explanation:

Case #1: We have only 10 units of paint which is not enough to draw both logos.
Case #2: We have 20 units of paint and following logos can, hence, be drawn.

/\
\/
/\
/  \
/
\/

This requires exactly 12 units, and we cannot do better

SAMPLE INPUT
3
10
20
30

SAMPLE OUTPUT
0 0
1 2
3 2
Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

## CODE EDITOR

Initializing Code Editor...

## This Problem was Asked in

Challenge Name

Remember December

OTHER PROBLEMS OF THIS CHALLENGE
• Basic Programming > Implementation
• Math > Number Theory
• Math > Linear Algebra