RRSUM - Wrong Answer

My code passes all the given input test cases but it is giving me a wrong answer on submission.Could someone please tell me where I am going wrong? Thanks in advance.

Following is the link to my code : http://ideone.com/zvSc3C

You are getting wrong answer due to overflow . the value of n<=10^9 therefore 3 * n <= 3 * 10^9 , which is greater than the range of the int type , so in your code change the type of int to unsigned int or long long int to solve the problem . Accepted code using both data types are linked .

Hope it helps.

If it helps , please upvote and accept it as right answer .

You need to use long long int instead of int… because 3*n when n = 10^9 cannot be stored as int.