Robotic moves
Practice
3.4 (89 votes)
Implementation
Basic programming
Problem
94% Success 22645 Attempts 10 Points 1s Time Limit 256MB Memory 1024 KB Max Code

A robot's initial position is \((0, 0)\) and it can only move along X-axis. It has \(N\) moves to make and in each move, it will select one of the following options:

  1. Go to \((X-1,0)\) from \((X,0)\)
  2. Go to \((X+1,0)\) from \((X,0)\)
  3. Remain at its current position

Your task is to calculate \(\sum ( abs(X)+abs(Y))\) for all reachable \((X,Y)\).

Note: Here, \(abs\) denotes the absolute value.

See the sample explanation for better understanding.

Input format

  • The first line contains \(T\) denoting the number of test cases.
  • The first line of each test case containing an integer \(N\) denoting the number of moves.

Output format

Print \(T\) lines. For each test case, print a single integer as described in the problem statement.

Constraints

\(1 \leq T \leq 20000\)

\(1 \leq N \leq 1e9\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:10
156 votes
Tags:
Basic ProgrammingBasics of ImplementationEasyImplementation
Points:10
20 votes
Tags:
Basic ProgrammingC++
Points:10
41 votes
Tags:
AlgorithmsSortingString Manipulation