HDOJ 1249 三角形『平面分隔』

很水拉   爲了記規律- -
php

題目連接:http://acm.hdu.edu.cn/showproblem.php?pid=1249spa

分隔平面公式blog

下面是我本身查找的公式,沒有推到過程,但能夠給一些連接ci

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

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

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

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

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

橢圓:f(n)=f(n-1)+2(n-1)=2+n(n-1);while

#include

#include

#include

usingnamespace std;

intmain(){

   int t,n;

   cin>>t;

   while(t--){

       cin>>n;

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

   }

   return 0;

}

相關文章
相關標籤/搜索