Solve for Sakura!!!
All submissions for this problem are available.Naruto really loves Sakura but Sakura likes Sasuke. Sakura gave a problem to Naruto to avoid him but Naruto is bent on solving it. He goes to Malhan for help but Malhan is no good at coding. Malhan really wants to help Naruto. Solve the problem for Malhan and help Naruto get Sakura. Sakura told Naruto to find **mth** element in **nth** row in Floyd's triangle. If value is not possible print -1. ![image](https://s3.amazonaws.com/hr-assets/0/1567264491-2e7ff0410b-floydstriangl...) **Special note** - Indexing of rows and elements in floyd triangle is from 1 ###Input: First line contains **T** i.e. no of testcases Next **T** lines will contain two integers **n** and **m** each **n** is row number **m** is element number ###Output: Output will contain **T** lines Each line will contain a single integer representing **mth** element in **nth** row If such element is not present print **'-1'** ###Constraints **1 <= T <= 10e5** **1 <= n <= 10e9** **1 <= m <= 10e9** ###Sample Input: 3 2 2 1 2 5 3 ###Sample Output: 3 -1 13
|Time Limit:||2 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, 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, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.