HDU 献给杭电五十周年校庆的礼物

题意:

中文。

思路:

这道神数学题无思路,百度之。。。

①n条线段最多把1个平面分成f[n] = f[n - 1] + 1个平面。

②想要把球体分成最多的块,第n刀与前n - 1个平面两两相交,这n - 1个平面把第n个面分成了f[n - 1]个平面,这样正好把原来的块数增加了f[n - 1]个。

也就是g(n) = g(n - 1) + f(n - 1);

Code:

#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
#include<bitset>
#include<set>
#include<map>
#include<cctype>
#include<vector>

#define TEST

#define LL long long
#define Mt(f, x) memset(f, x, sizeof(f));
#define rep(i, s, e) for(int i = (s); i <= (e); ++i)
#ifdef TEST
    #define See(a) cout << #a << " = " << a << endl;
    #define See2(a, b) cout << #a << " = " << a << ' ' << #b << " = " << b << endl;
    #define debug(a, s, e){ rep(_i, s, e) {cout << a[_i] << ' '; }cout << endl;}
    #define debug2(a, s, e, ss, ee) rep(i_, s, e) {debug(a[i_], ss, ee);}
#else
    #define See(a)
    #define See2(a, b)
    #define debug(a, s, e)
    #define debug2(a, s, e, ss, ee)
#endif

const int MAX = 2e9;
const int MIN = -2e9;
const int PI = acos(-1.0);
const double eps = 1e-8;

using namespace std;

LL f[1005];

int main()
{
    f[1] = 2;
    for(LL i = 2; i <= 1000; ++i)
    {
        f[i] = f[i - 1] + i * (i - 1) / 2 + 1;
    }
    int n;
    while(~scanf("%d", &n))
    {
        printf("%lld\n", f[n]);
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值