2n条直线划分平面总数为2n^2+n+1;
除去4n条边和2n个顶点后变成n条折线,由欧拉公式可得面数减少2n,即2n^2-n+1;
#include<math.h> #include<stdio.h> #include<stdlib.h> #include<string.h> int main(void) { int t,n; long long f[20001]; f[0]=1; for(int i=1; i<20001; i++) f[i]=f[i-1]+i; scanf("%d",&t); while(t--) { scanf("%d",&n); printf("%I64d\n",f[2*n]-2*n); } return 0; }
时间: 2024-10-29 19:11:39