#206. 积木三角形总数(递归求解)

    ID: 206 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatWarmup-2gesp5递归数学基础

积木三角形总数(递归求解)

Block Triangle

Background

Dawei is playing with blocks. He enjoys building various shapes with them, and one of his favorites is a triangle.

Problem Description

We have a triangle made of blocks. The topmost row has 11 block, the next row down has 22 blocks, the next row has 33 blocks, and so on. Compute recursively (no loops or multiplication) the total number of blocks in such a triangle with the given number of rows.

Input Format

Input is given from Standard Input in the following format.

rows

Output Format

Output is printed to Standard Output in the following format.

total_blocks

Sample

0
0
1
1
2
3

Sample Explanation

For 00 rows, there are 00 blocks in total. For 11 row, there is 11 block in total. For 22 rows, there are 1+2=31 + 2 = 3 blocks in total.

Constraints

Time limit: 11 second, Memory limit: 10241024 KiB for each test case.