跳到正文

题解

题解:UVA13108 Juanma and the Drinking Fountains

cff_0102约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟
获赞
4
题目
UVA13108

版本

  1. v1当前

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

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

C++
#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;
}
原文