UVa 10079 - Pizza Cutting

传送门

UVa 10079 - Pizza Cutting

题意

求n刀最多能切几块

思路

耍赖了,上OEIS查了一下。

\[f\left( n\right) =\dfrac {n * \left( n+1\right) } {2} + 1\]

代码

#include <bits/stdc++.h>
#define LL long long
using namespace std;
 
int main()
{
    LL ans, n;
    while (~scanf("%lld", &n), n >= 0)
        printf("%lld\n", n * (n + 1) / 2 + 1);
    return 0;
}

Powered by Jekyll and Theme by solid