题意:
圆周上有互不重合的2≤N≤105个点,将这N个点两两相连(圆内没有三条线交于一个点的情况)
求图形中一共有多少个交点(包括边界上的点)
分析:
我们发现内部交点的是由4个点形成的四边形的对角线交点产生的
那么内部总交点数就是不同的四边形的个数,再加上圆周上的N个点
ans=C4n+n
虽然结果不爆LL,但中间结果炸了LL,但在ULL范围内
代码:
//
// Created by TaoSama on 2016-02-06
// Copyright (c) 2016 TaoSama. All rights reserved.
//
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>
using namespace std;
#define pr(x) cout << #x << " = " << x << " "
#define prln(x) cout << #x << " = " << x << endl
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;
int n;
int main() {
#ifdef LOCAL
freopen("C:\\Users\\TaoSama\\Desktop\\in.txt", "r", stdin);
// freopen("C:\\Users\\TaoSama\\Desktop\\out.txt","w",stdout);
#endif
ios_base::sync_with_stdio(0);
int t; scanf("%d", &t);
while(t--) {
scanf("%d", &n);
unsigned long long ans = 1ull * n * (n - 1) / 2 * (n - 2) / 3 * (n - 3) / 4;
ans += n;
printf("%I64u\n", ans);
}
return 0;
}