数数小木块

L. 数数小木块

Description

在墙角堆放着一堆完全相同的正方体小木块,如下图所示:

因为木块堆得实在是太有规律了,你只要知道它的层数就可以计算所有木块的数量了。

Input

只有一个整数 n ,表示这堆小木块的层数,已知1 <= n <= 100 。

Output

只有一个整数,表示这堆小木块的总数量。

Sample Input

5

Sample Output

35
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,a,n=0;
    cin>>a;
    for(i=1;i<=a;i++)
    {
        for(j=a;j>=1;j--)
        {
            if(i+j-1==a)
            {
                n+=i*j;
            }
        }
    }
    cout<<n<<endl;
    return 0;
}

 

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
分享
二维码
< <上一篇
下一篇>>