TIle cost not able to resolve this

https://hack.codingblocks.com/app/practice/3/p/288
please tell me how to approach this question I am unable to understand this question please tell me some hint about this question

Hey @jaiskid,
The question calls for calculating the sum of all the costs for each tile of length ranging from l to r.
To calculate the cost of a tile of side length x,
we have xxa+x*b+c
Hope it helps.

If the question is clear to you mark the doubt as resolved and you can give rating too if you wish to.:grinning:

@Yashwardhan_Gautam hello bhaiya can you please check this lines of codes.

First of all the ans variable will be initialised with 0 and not 1.
Secondly, The the answer variable need to be updated using addition and not multiplication also refer to the above formula to upgrade answer.
For every value of i, the cost will increase by a per unit area, or iia.
Give it another shot. Hope you’ll be able to crack it now.

Also check the constraints first,
You’re not taking care of the test cases also.
Plus iterating over all elements from L to R will also not work, since the size is 10^9.
Try adding the coefficients of a,b in O(1).
Hint - use sum of squares of first n terms, and sum of first n terms.

Check this code for reference.
You can remove the comment in order to debug.
PS: this is just for your reference, you should try writing the code on your own.

@Yashwardhan_Gautam I am working on it bhaiya

Okay @jaiskid,
Let me know if you face any problems.
The crux of this question is to find the cost in O(1) and if you are aware of inverse modulo exponentiation or not.

@Yashwardhan_Gautam no bhaiya I have no idea of inverse modulo exponention

Don’t worry, it’ll get covered in this course.

@Yashwardhan_Gautam bhaiya apaar bhaiya was already discuss about binary exponention and modular exponention but he didn’t discuss about this is there any video or reference belong to this inverse mod

check personal chat @jaiskid.
We can talk there.