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.

Input

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

Output

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

Sample test(s)
input
2
output
3
input
3
output
7
Note

Consider the first test sample. Manao can fail his first push and push the wrong button. In this case he will already be able to guess the right one with his second push. And his third push will push the second right button. Thus, in the worst-case scenario he will only need 3 pushes.

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int s=;
for(int i=;i<=n;i++)
{
s+=+(n-i)*i;
}
cout<<s<<endl;
}

Codeforces Round B. Buttons的更多相关文章

  1. Codeforces Round #284 (Div. 2)A B C 模拟 数学

    A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard ...

  2. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  3. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  4. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  5. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  6. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  7. Codeforces Round #262 (Div. 2) 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

  8. Codeforces Round #262 (Div. 2) 1004

    Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...

  9. Codeforces Round #370 - #379 (Div. 2)

    题意: 思路: Codeforces Round #370(Solved: 4 out of 5) A - Memory and Crow 题意:有一个序列,然后对每一个进行ai = bi - bi  ...

随机推荐

  1. Android接入支付宝和银联

    支付宝接入参考链接:https://software.intel.com/zh-cn/node/542608 银联接入参考链接:http://blog.csdn.net/gf771115/articl ...

  2. QT中将ASCII转换为对应数值的方法

    有时候需要将一段ASCII转换为数值进行传输(比如串口) QString str=codeEdit->toPlainText(); QVector<uint>v=str.toUcs4 ...

  3. 关于学习JavaScript 的 高三编程 一些心得(二)

    今天在看高三的过程中,解决了之前我在 面试过程中遇到的一个问题. 就是将一段英文 颠倒过来. 下面就是我的代码: var zhang = "my name is zhangge !" ...

  4. hdu4790 Just Random (数学?)

    acm.hdu.edu.cn/showproblem.php?pid=4790 题意:x随机取a~b,y随机取c~d,求(x+y)mod p = m 的概率.(结果用分数表示) 题解: 数学概率题,运 ...

  5. JavaScript模板引擎原理,几行代码的事儿

    一.前言 什么是模板引擎,说的简单点,就是一个字符串中有几个变量待定.比如: var tpl = 'Hei, my name is <%name%>, and I\'m <%age% ...

  6. 多线程更新UITableView时容易导致的问题

    我请求同一个接口两次, 第一次是那缓存, 第二次是那网络数据在请求成功回调的主线程异步的, 先赋值数据源, 然后调用uitableview reloaddata的方法, 这时候问题来了 reloadd ...

  7. Win10安装程序出现error code 2502 2503

    在Win10中,在安装msi安装包的时候常常会出现代码为2502.2503的错误.其实这种错误是由于安装权限不足造成的,可以这种msi的安装包不像其他exe的安装程序,在安装包上点击"右键& ...

  8. c#接口

    //接口中方法 属性 事件等默认都是public 不允许用修饰符修饰 public interface IEventInterFace { string this[int index] { get; ...

  9. C#与Java多态方面的语法差异

    C++.C#.Java,无奈三种语言让我多次混淆,多次搞清楚,不写个Demo我想还是会忘记的. 就好像是一个满水的杯子,倒掉一点,才能装下更多. 有时候博客就是一个倒水的地方,可以让我们清空自己,然后 ...

  10. go:defer

    defer:延迟. 假设有调用函数A.被调用函数B,其关系如下: func A(){//调用函数 ... defer B()//被调用函数 ... return//B将延迟到return前执行 } * ...