Counting regions —— 多边形对角线分割区域个数

题目描述
Niuniu likes mathematics. He also likes drawing pictures. One day, he was trying to draw a regular polygon with n vertices. He connected every pair of the vertices by a straight line as well. He counted the number of regions inside the polygon after he completed his picture. He was wondering how to calculate the number of regions without the picture. Can you calculate the number of regions modulo 1000000007?It is guaranteed that n is odd.输入描述:The only line contains one odd number n(3 ≤ n ≤ 1000000000), which is the number of vertices.输出描述:Print a single line with one number, which is the answer modulo 1000000007.
示例1
输入复制
3
输出复制
1
示例2
输入复制
5
输出复制
11备注:
The following picture shows the picture which is drawn by Niuniu when n=5. Note that no three diagonals share a point when n is odd.

有一个公式是对奇数的时候有作用的,我自己做的时候推,推不出来= =!
c++的时候也wa了,估计是哪里没处理到位,还好有python

n=input();
n=eval(n);
n=n*n*n*n-6*n*n*n+23*n*n-42*n+24;
n=n//24;
n=n%1000000007;
print(n);

你可能感兴趣的:(数学)