I checked out solutions of chef and ingredients question but still could not understand. Can anyone please help me with the approach.

You just need to try

solving it on paperâ€¦

for first subtask you will notice that

when you give an input n=4 (answer is 6)

n=5 (answer is 10)

if you properly write it on paper it will be

for n=4, the numbers skipped will be 3,2,1â€¦

for n=5, the numbers skipped will be 4,3,2,1â€¦

so this is a series and itâ€™s formula is n*(n-1)/2

when you do it for second subtask.

Try seeing the patternâ€¦

(Hint, itâ€™s an AP)

I tried the â€śOEISâ€ť approach, it gave me what seems to be good results (was comparing my oracle bruteforce solution with the formula I took from the oeis sequences), but still couldnâ€™t pass the second subset of tests.

Others solutions seems to use an entirely different formulaâ€¦ Was the oeis solution a wrong way to do, but â€śmagicallyâ€ť working for N <= 8?

For examples, theses sequences: https://oeis.org/A130518, https://oeis.org/A130520 (with an offset related to N).

Edit: Dat -92 rating drop