牛客網暑期ACM多校訓練營(第八場)G Counting regions【幾何公式推導】
阿新 • • 發佈:2018-12-24
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<iomanip>
using namespace std;
const int maxn = 1e5 + 12;
#define ll long long int
#define Build build
#define Node node
#define MAT mat
#define charmax(a,b) a=max(a,b)
#define charmin(a,b) a=min(a,b)
#define clr(a,b) memset(a,b,sizeof a)
const ll mod = 1e9 + 7;
bool vis[maxn];
int prim[maxn];
int a[maxn];
//I'm very sorry for my friends and our team "goodbye".That's not my time to say goodbye.I'm back now! ——Irish_Moonshine
//(n-1)(n-2)(n^2-3n+12)/24
ll qkm(ll a, ll b) {
ll ans = 1 ;
while (b > 0) {
if (b % 2) ans = ans * a; ans %= mod;
a = a * a; a %= mod;
b >>= 1;
}
return ans;
}
int main()
{
ll ans = 0;
ll n;
scanf("%lld", &n);
ans = (n - 1)*(n - 2) % mod;
//cout << ans << endl;
ans *= (n*n%mod-3 *n+12+mod); ans %= mod;
ans *= qkm(24, mod - 2); ans %= mod;
(ans += mod) %= mod;
printf("%lld\n", ans);
return 0;
}