题库练习 Buttons
← 上一题 下一题 →

A8773 | Buttons

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Manao is trying to open a rather challenging lock. The lock has $n$ buttons on it and to open it, you should press the buttons in a certain order to open the lock. When you push some button, it either stays pressed into the lock (that means that you've guessed correctly and pushed the button that goes next in the sequence), or all pressed buttons return to the initial position. When all buttons are pressed into the lock at once, the lock opens.

Consider an example with three buttons. Let's say that the opening sequence is: {2, 3, 1}. If you first press buttons 1 or 3, the buttons unpress immediately. If you first press button 2, it stays pressed. If you press 1 after 2, all buttons unpress. If you press 3 after 2, buttons 3 and 2 stay pressed. As soon as you've got two pressed buttons, you only need to press button 1 to open the lock.

Manao doesn't know the opening sequence. But he is really smart and he is going to act in the optimal way. Calculate the number of times he's got to push a button in order to open the lock in the worst-case scenario.

输入格式

A single line contains integer $n$ ( $1<=n<=2000$ ) — the number of buttons the lock has.

输出格式

In a single line print the number of times Manao has to push a button in the worst-case scenario.

输入输出样例

输入 #1
2
输出 #1
3
输入 #2
3
输出 #2
7
C++ 编辑器
输入
输出