Drawing Lines - SGU 135(简单递推)

求N条直线最多能把一个平面分成几部分。

 

代码如下:

==============================================================================================================================

#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<vector>
using namespace std;

const int MAXN = 16007;

int main()
{
    int ans=1, N;

    scanf("%d", &N);

    for(int i=1; i<=N; i++)
        ans += i;

    printf("%d\n", ans);

    return 0;
}

 

posted @ 2015-10-05 19:37  无忧望月  阅读(171)  评论(0)    收藏  举报
levels of contents