All submissions for this problem are available.
Given two numbers x and y, find the squares of x, x+1, x+2, ... , x+n where x+n=y. After calculating the squares of all those numbers, find the difference between every two consecutive squares. You will get n such numbers. Now, square the n numbers that you get and add them. Display the result mod 109+7.Note that always x<y.
The first line of input contains an integer T denoting the number of testcases. Each test case contains two space-separated integers x and y.
Print the result mod 109+7 in a new line.
- 1 ≤ T ≤ 105
- 0 ≤ x,y ≤ 105
Input: 1 1 4 Output: 83
There are 4 numbers. The square of 1 is 1, square of 2 is 4, square of 3 is 9 and square of 4 is 16.
Now calculate the difference between every two consecutive squares. Now,we have 3, 5 and 7. Square each of them and add them i.e. 3^2 + 5^2 + 7^2 = 9 + 25 + 49 = 83.
|Time Limit:||1 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, LISP sbcl, LISP clisp, SCM guile, ERL, TCL, kotlin, TEXT, SCM chicken, FS|
Fetching successful submissions