容斥 组合排列
代码:
#include <iostream> #include <cstdio> #include <map> #include <algorithm> #include <cstring> #include <string> #define ll long long using namespace std; const int N=1005; const long long LINF=(long long)(1e18); ll c[N][N]; ll a[N]; void FC(int n) { for(int i=0;i<=n;++i) for(int j=0;j<=i;++j) if(i==j||j==0) c[i][j]=1; else c[i][j]=c[i-1][j-1]+c[i-1][j]; a[0]=1; for(int i=1;i<=n;++i) a[i]=a[i-1]*i; } class TheHexagonsDivOne { public: long long count(int n) { FC(2*n); if(n<=3) return 0; ll tmp=2*n; --n; ll sum=0; sum+=(c[2*n][6]*a[6]/6); sum-=(c[n][1]*c[2*(n-1)][4]*12*a[4]/6); sum+=(c[n][2]*c[2*(n-2)][2]*12*6*a[2]/6); sum-=(c[n][3]*c[2*(n-3)][0]*12*4*2*a[0]/6); return sum*tmp; } };