C Wangxiao cake cutting SDUT


Description

Wangxiao boast a good knife, a large pancake was put on the chopping block, and asked him: "? Not allowed to leave the cake cutting board, cut n (1 <= n <= 100) can be divided into a maximum number of knife block"


Input

Enter the number of cutting knife n.


Output

Cutting n number of blocks knife up output is cut cake.


Sample
Input

100


Output

5051


Hint


This question in fact we have had this title in junior high school: a plane up to be "n" number of lines divided into blocks, is the same here, looking with "n" to increase the number of copies to be split What really changes : 2,4,7,11,16 ......
regularities good looking 2 + 2 + 4,4 = 7,7 = 3 + 4 + 5 = 16 = 11, 11 ......
recursive equation: a [n ] = n-1] + n +1 a [;

#include <stdio.h>
#include <stdlib.h>
  int main()
  {
      int n,i;
      long long a[100]={0};
      a[0] = 2;
      scanf("%d",&n);
      for(i=1;i<n;i++)
      {
          a[i] += a[i-1]+i+1;
      }
      printf("%lld\n",a[i-1]);

      return 0;
  }
Published 162 original articles · won praise 119 · Views 3008

Guess you like

Origin blog.csdn.net/zhangzhaolin12/article/details/104045548