Sequential tuples
Practice
4 (13 votes)
Dynamic programming
Algorithms
Introduction to dynamic programming 1
Problem
91% Success 2630 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You have infinite cards for each number between $$1$$ and $$N$$ (inclusive of them). Your task is to select three integers such that after sorting them in ascending order, the difference between the adjacent number is less than or equal to two. Find the number of ways to choose three numbers and print them.

Note: The order of numbers does not matter.

Input format

  • The first line contains an integer $$T$$ denoting the number of test cases.
  • For each test case, the first and only line contains an integer $$N$$.

Output format

Print $$T$$ lines, one for each test case, denoting the number of ways.

Constraints

\(1 \leq T \leq 20000\)

\(1 \leq N \leq 200000\)

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
61 votes
Tags:
Dynamic ProgrammingAlgorithmsIntroduction to Dynamic Programming 1
Points:30
34 votes
Tags:
AlgorithmsDynamic Programming
Points:30
500 votes
Tags:
Dynamic ProgrammingEasy