https://www.codechef.com/CCSTART2/problems/ADDNATRL

Your logic is correct. Just use long int or long long instead of int for n and sum as contraints are till 10^9. It should give AC then.

You might search your doubt on the forum before posting straightaway.

1 Like