RUN, CHEF, RUN !!!

All submissions for this problem are available.
Chef took part in a race event ,in which the length of racing track is $N$ miles. However there are checkpoints at an interval of $K$ miles from the starting point onward, i.e at the distance of $K,2K,3K...$ from the starting point. On reaching each checkpoint Chef has to return back to the starting point to restart his race, and the visited checkpoint is removed. Chef is busy preparing himself for the race,so he wants you to find out the total distance he has to cover in order to complete the race successfully. The race is said to be successfully completed if all the checkpoints at a distance $d$ $(d \leq N)$ is removed. The result can be very large, so compute it modulo 1000000007 ($10^9 + 7$) ###Input:  First line contains $T$, number of test cases. Then the test cases follow.  Each test case contains two space separated integers $N$ and $K$ ###Output: For each test case, output in a single line answer i.e total distance chef needs to cover to complete his race modulo 1000000007. ###Constraints  $1 \leq T \leq 25$  $1 \leq N\leq 10^{12}$  $1 \leq K\leq 10^5$ ###Sample Input: 2 3 2 4 2 ###Sample Output: 7 16 ###EXPLANATION: In $1st$ case : $N = 3$ and $K = 2$ ,therefore there is only one checkpoint in the racing track. So Chef runs 2 miles and reaches the checkpoint. From here he has to return back to starting point i.e 2 miles. Now as there are no more checkpoints yet to be reached so he can cover the remaining distance i.e. 3 miles in a go. So total distance is $2+2+3 = 7 miles$.Author:  shrivas7 
Editorial  https://discuss.codechef.com/problems/ENOC4 
Tags  arithmeticprogression, easy, enoc2019, modulararith, shrivas7 
Date Added:  22102019 
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, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions