HDOJ 1249 三角形『平面分隔』

很水拉   为了记规律- -

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1249

分隔平面公式

下面是我自己查找的公式,没有推到过程,但可以给一些链接

http://hi.baidu.com/matrixwhisper/item/6bfe48522351e0d19e266717

http://qianmacao.blog.163.com/blog/static/203397180201212193457357/

直线:f(n)=f(n-1)+n=1+n(n-1)/2;

折线:f(n)=f(n-1)+(4n-3)=2*n*n-n+1;

三角形:f(n)=f(n-1)+6(n-1)=3n(n-1)+2;

椭圆:f(n)=f(n-1)+2(n-1)=2+n(n-1);

#include

#include

#include

usingnamespace std;

intmain(){

   int t,n;

   cin>>t;

   while(t--){

       cin>>n;

       cout<<3*n*(n-1)+2<<endl;

   }

   return 0;

}


原文地址:https://www.cnblogs.com/XqwKen/p/4564324.html