hdu 2050 折线分割平面 (找规律,递推)

hdu 2050题目链接

题意:n条折线。。最多能把平面分成几部分。。 思路:联想到m条直线,最多能把平面分成m*(m+1)/2+1部分。。

画图发现。。。 f[2*n-1]==g[n]。。

 1/* ***********************************************
 2Author :111qqz
 3Created Time :2016年07月27日 星期三 20时28分57秒
 4File Name :code/hdu/2050.cpp
 5************************************************ */
 6
 7#include <cstdio>
 8#include <cstring>
 9#include <iostream>
10#include <algorithm>
11#include <vector>
12#include <queue>
13#include <set>
14#include <map>
15#include <string>
16#include <cmath>
17#include <cstdlib>
18#include <ctime>
19#define fst first
20#define sec second
21#define lson l,m,rt<<1
22#define rson m+1,r,rt<<1|1
23#define ms(a,x) memset(a,x,sizeof(a))
24typedef long long LL;
25#define pi pair < int ,int >
26#define MP make_pair
27
28using namespace std;
29const double eps = 1E-8;
30const int dx4[4]={1,0,0,-1};
31const int dy4[4]={0,-1,1,0};
32const int inf = 0x3f3f3f3f;
33int main()
34{
35	#ifndef  ONLINE_JUDGE 
36	freopen("code/in.txt","r",stdin);
37  #endif
38
39	int T;
40	cin>>T;
41	while (T--)
42	{
43	    int n;
44	    scanf("%d",&n);
45	    n =2*n-1;
46	    printf("%d\n",n*(n+1)/2+1);
47	}
48
49  #ifndef ONLINE_JUDGE  
50  fclose(stdin);
51  #endif
52    return 0;
53}