题解:UVA13108 Juanma and the Drinking Fountains

· · 题解

题意简述:一个圆上有 n 个点,问它们两两相连最多可以把圆分成几个部分。

由 https://oeis.org/A000127 可得答案为 \dfrac{n^4 - 6n^3 + 23n^2 - 18n + 24}{24}。

#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    int t;cin>>t;
    while(t--){
        long long n;cin>>n;
        cout<<(n*n*n*n-6*n*n*n+23*n*n-18*n+24)/24<<"\n";
    } 
    return 0;
}