https://www.codechef.com/problems/FFC219B

my code

I have used the summation formula for first n numbers ,first n^2 numbers so on till first n^4 numbers .
The test case is passing but I’m getting WA.
Please can anyone help me.

Your link is just the editor link.

1 Like

you don’t need n^2 or n^4 its just pattern.
example:
day 1- 1.2.3.4 = 24
day 2- 2.3.4.5 = 120
day 3- 3.4.5.6 = 360
day 4- 4.5.6.7 = 840

just pre compute the results

can u pls tell why this code gives WA?
https://www.codechef.com/viewsolution/26918244

The code gives segmentation even for the given sample test case in the problem. Did you even test it?

l and r both have to be inclusive. In yours if l=1 then it will be vec[r]-vec[0] so 1st day will not be included