P5377 鸽鸽的分割 评论及c++题解

P5377 鸽鸽的分割

1.原题连接

root

2.评论

下位红(划掉
简单题
只需要推导出公式或分类讨论就行了
这里只给出公式解法
根据题意 在一个圆上确定n (n∈正整数) 个点,求最多可被划分出的区域
首先明确一下 当n<2时,没有线 返回1
... //繁琐的推导
那么就可以得出
ans=(n^4 -6n^3 +23n^2-18n)/24+1
oeis.org A000127
懂得都懂

3.题解

以下是满分代码:

#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n;
int main(){
    while(cin>>n){
        if(n==1 || n==0){
            cout<<"1"<<endl;
        }
        else cout<<(n*n*n*n-6*n*n*n+23*n*n-18*n)/24+1<<endl;
    }
    return 0;
}
posted @ 2022-10-26 23:38  織田信長  阅读(36)  评论(0)    收藏  举报
Title