I have got the power!
All submissions for this problem are available.
Deadpool envies other Marvel heroes like Ironman, Thor, Spiderman because all of them have the power to fly. Deadpool has a notion that probably after the mutation, he too has the power to fly or atleast jump high. So to try, he went atop a tower, the height of buildings in NY increase and decrease alternatively.
Deadpool has put his maximum effort and jumped as many towers as possible.Let us denote d[i] as the height of the ith tower and the alternate increase, decrease as a marvel number. Formally, a marvel number is a series of towers is defined as d < d > d …. or d > d < d…
Given a number N, Deadpool wants to find the integers L and R such that the range [L,N] and [N,R] each contain exactly K marvel numbers. Also he wants these ranges to be as large as possible.
Note: Note that if no L >= 1 is found or the required value of R exceeds 10^18, you should print "-1".
The first line of input file contains T, the number of test cases to follow.
Each of the following T lines contain two space-separated integers N and K.
Output exactly T lines, each containing two integers L and R sepated by a single space.
- 1 ≤ T ≤ 625
- 1 ≤ K,N ≤ 10^18
Input: 2 9 2 2 3 Output: 8 11 -1 4
Problem Setter : Shubham Chauhan
|Time Limit:||5 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.