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 \)
Submissions
Please login to view your submissions
Similar Problems
Points:30
5 votes
Tags:
Basic MathC++Math
Points:50
12 votes
Tags:
Data StructuresGraph TheoryOpenDivide-and-conquer algorithmHardAlgorithms
Points:30
3 votes
Tags:
C++Basic MathObservationMath
Editorial