设为首页 加入收藏

TOP

BZOJ 1845三角形面积并
2015-07-24 05:43:44 来源: 作者: 【 】 浏览:4
Tags:BZOJ 1845 三角形 面积

?

给定100个三角形,求三角形面积并。

戴神模板太可怕,直接调用函数秒掉,思路有点繁琐,不大清楚,贴一个代码。

代码:

?

/* ***********************************************
Author :rabbit
Created Time :2014/7/3 22:46:38
File Name :2.cpp
************************************************ */
#pragma comment(linker, /STACK:102400000,102400000)
#include 
  
   
#include 
   
     #include 
    
      #include 
     
       #include 
      
        #include 
       
         #include 
        
          #include 
         
           #include 
          
            #include 
           
             #include 
            
              #include 
             
               #include 
              
                #include
                using namespace std; #define INF 0x3f3f3f3f #define eps 1e-8 #define pi acos(-1.0) typedef long long ll; int dcmp(double x){ if(fabs(x)
                
                 0?1:-1; } struct Point{ double x,y; Point(double _x=0,double _y=0){ x=_x;y=_y; } }; Point operator + (Point a,Point b){ return Point(a.x+b.x,a.y+b.y); } Point operator - (Point a, Point b){ return Point(a.x-b.x,a.y-b.y); } Point operator * (Point a,double p){ return Point(a.x*p,a.y*p); } Point operator / (Point a,double p){ return Point(a.x/p,a.y/p); } bool operator < (const Point &a,const Point &b){ return a.x
                 
                  0)return 1; return 0; } }; struct polygons{ vector
                  
                    p; polygons(){ p.clear(); } void push(polygon q){ if(dcmp(q.getarea()))p.push_back(q); } vector
                   
                     > e; void ins(Point s,Point t,Point X,int i){ double r=fabs(t.x-s.x)>eps?(X.x-s.x)/(t.x-s.x):(X.y-s.y)/(t.y-s.y); r=min(r,1.0);r=max(r,0.0); e.push_back(make_pair(r,i)); } double polyareaunion(){ double ans=0; int c0,c1,c2; for(int i=0;i
                    
                     0?c0*((j>i)^(c0<0)):-(c0<0)); if(dp&&c3)ins(s,t,b,dp>0?-c3*((j>i)^(c3<0)):c3<0); } } } sort(e.begin(),e.end()); int ct=0; double tot=0,last; for(int j=0;j
                     
                      

?

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇HDU 3488Tour(网络流之最小费用流.. 下一篇并发理解(阻塞队列)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: