I provided this answer, but do not know where is the problem. The answer I get from this code was same when compared to the given input and output. Can someone help?
Hi, use long long
data type, it will work.
Here’s what I understood, first let’s look at the constraints:
Here the maximum value of Ai can be 10^6, now let’s take an example:
Test Case:
1
3
1 1000000 1000000
So, the maximum value for this case will be (1000000-1)*1000000
i.e 999999000000
, and now if you choose int
data type then it will not be covered as the maximum value of int
can be 2147483647
which is lesser than 999999000000
, so you just need to use a data type that has a greater range.