All submissions for this problem are available.
One day Gautam Khan was very eager to eat Vadai.
He wanted to eat as much vada as possible. There were infinite vadais in front of him which are arranged in a line and numbered from 1 (1 2 3 4 .....)and he decided to eat them in N steps.In each step he can eat X vadais , X is between 0 to N^2 vadai (eg N=2 , then he can eat 0 vadai or 1 vadai or 2 vadais or 3 vadais or 4 vadais) and after eating X vadais , he will sleep in the place where the last vadai in that step was kept( i.e., At each step , after eating the vadais he will sleep at the place where he ate the last vadai). But one of the vadai is rotten which is at position M and he will not sleep at that place but he can still eat it.Find maximum no of vadais Gautam can eat without sleeping at the place of rotten vadai at M.
The first Line contains T , the no of test cases followed by T lines.
Each line has 2 integers N,M.
Output has T lines ,with each line containing no of maximum vadai gautam can eat .Since answer A can be too large, print A modulo 1000000007.
5 1 1 2 2 3 2 4 3
0 5 14 30
1<= N <=2,000 1<= M <= 4,000,000
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, 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, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.