hdu2050(递推)

来源:互联网 发布:怎样在mac上qq群视频 编辑:程序博客网 时间:2024/05/16 18:14
/*不管折现 我们考虑直线的话那么 ,多一条线多一个点,那么折线类似自己画一下因为自己不可能和自己相交所以多一条折线多,多2*n个点,那么面数比多出来的点数多1所以就有了公式,a[j] = a[j-1] + 4*(j-1) + 1*/#include <iostream>#include <cstdio>using namespace std;typedef long long ll;ll a[10010];int main(){    int n;    while(scanf("%d", &n) != EOF){        while(n--){            int t;            scanf("%d", &t);            a[1] = 2;            for(int j = 2; j <= t; j++){                a[j] = a[j-1]+4*(j-1)+1;            }            cout << a[t] << endl;        }    }    return 0;}

0 0