Maximum sum
Practice
0 (0 votes)
Hiring
Open
Hiring
Open
Implementation
Hiring
Mathematics
Easy
Basic programming
Mathematics
Mathematics
Mathamatics
Problem
58% Success 134 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given a positive integer \(N\). Your task is to determine the maximum value of \(X\), where for any value of \(K\) between \(1\) to \(N\), the value of \(X\) is as follows:

\( X = \sum\limits_{i=1}^K ((-1)^{i+1})(i)(i+1) \) .

Input format

  • First line: \(T\) denoting the number of test cases
  • Next \(T\) lines: A single integer \(N\)

Output format

For each test case, print the maximum value of \(X\).

Constraints

\( 1 \le T \le 10^{5} \)

\( 1 \le N \le 10^{9} \)

\( 1 \le K \le N \)

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:30
10 votes
Tags:
MathPrefixBasic MathBasic ProgrammingDynamic Programming
Points:30
3 votes
Tags:
C++Basic MathObservationMath
Points:30
1 votes
Tags:
MathematicsMediumOpenApprovedMathamatics