Section 1.4: Optimization
Course Progress
100%
Problem
Submissions
Leaderboard
Solution

Bob runs a tile shop. He sells only square tiles. He charges $a per unit area and $b per unit length of its side. Moreover, he also charges a constant amount of $c for each tile. He asks you to calculate the total amount he gets after selling exactly one tile of side length x in range [l,r]. Bob knows that his earnings is beyond your calculation, so he asks you to calculate amount modulo (109+7).

Input Format

First line contains number of test cases, T. Each test case contains 5 integers, a, b, c, l, r.

Constraints

1 <=T<=10^5
1<=a,b,c,l,r<=10^9

Output Format

Output a single integer denoting answer as per the problem statement.

Sample Input

1
1 1 1 1 10

Sample Output

450

Problem
Submissions
Leaderboard
Solution
Result Score Time Language
ACCEPTED 200/200 100ms C++ View 10 mins ago
COMPILATION ERROR 100/200 200ms C View 10 mins ago
WRONG ANSWER 40/200 150ms Python View 10 mins ago
RUNTIME ERROR 50/200 150ms Python View 10 mins ago
TLE 100/200 150ms Python View 20 mins ago
MLE 200/200 150ms C++ View 40 mins ago
Problem
Submissions
Leaderboard
Solution
Rank User College Language Score
#40
Siddharth Jain
JSS Noida C++ 2345
01
Siddharth Jain
JSS Noida C++ 2345
02
Siddharth Jain
JSS Noida Python 2345
03
Siddharth Jain
JSS Noida Python 2345
04
Siddharth Jain
PEC, Chandigarh C 2345
05
Siddharth Jain
JSS Noida Python 2345
06
Siddharth Jain
PEC, Chandigarh C++ 2345
07
Siddharth Jain
JSS Noida Python 2345
08
Siddharth Jain
JSS Noida C++ 2345
09
Siddharth Jain
JSS Noida C 2345
Prev 1-20 of 245 Next
Problem
Submissions
Leaderboard
Solution
Editorial Locked
If you unlock the editorial, you will not be awarded any score for this problem