Author: | I. Tuphanov | |||
Input file: | input.txt | Time limit: | 1 sec | |
Output file: | output.txt | Memory limit: | 256 Mb |
Young programmer Vasya is learning the beginnings of the algorithm complexity theory. For starters, he wants to be able to quickly estimate the number of iterations of nested loops. As a first example, he wrote the following code:
C | Pascal |
long long f(int n) { long long ans = 0; for (int i = 1; i <= n; i++) for (int j = i+1; j <= n; j++) for (int k = j+1; k <= n; k++) ans++; return ans; } |
function f(n: integer): int64; var i, j, k: integer; begin result := 0; for i := 1 to n do for j := i+1 to n do for k := j+1 to n do inc(result); end; |
Using your knowledge of the subject,
help Vasya calculate f(n)
for given n.
Input file contains an integer n.
Output file must contain a single integer — f(n)
.
1 ≤ n ≤ 106
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|
2 |
|
|
Author: | A. Klenin | |||
Input file: | input.txt | Time limit: | 2 sec | |
Output file: | output.txt | Memory limit: | 200 Mb |
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|
2 |
|
|