设为首页 加入收藏

TOP

UVA 11722(概率+几何)
2015-11-21 01:02:32 来源: 作者: 【 】 浏览:2
Tags:UVA 11722 概率 几何

?

Problem

12345

Solution

求概率方法就是lrj的方法。怎么求面积比,又不要分太多情况讨论呢?首先,线段与直线相交怎么判断,直线与直线求交点怎么求,然后,怎么把四边形的面积转换为三个三角形面积相加,怎么判断两条直线之间没有夹四边形的情况?解决这些情况就行了,基本模板大白书都有。

My code

//Hello. I'm Peter.
#pragma comment(linker, /STACK:102400000,102400000)
#include
   
     #include
    
      #include
     
       #include
      
        #include
       
         #include
        
          #include
         
           #include
          
            #include
           
             #include
            
              #include
             
               #include
              
                #include
               
                 #include
                
                  #include
                 
                   #include
                   using namespace std; typedef long long ll; #define peter cout<'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } const double eps=1e-9; int dcmp(double x){ if(fabs(x)
                    
                     &res){ res.clear(); for(int i=1;i<=4;i++){ if(!Line_Inter_Segment(l,seg[i])) continue; Point p1=Poi_LineInterLine(l.p,l.v,seg[i].p1,seg[i].p2-seg[i].p1); int len=(int)res.size(); bool ok=true; for(int j=0;j
                     
                      res; double ansS=abs(t2-t1)*abs(s2-s1); int len; get_p(l1,res); len=(int)res.size(); if(len>1){ sort(res.begin(),res.end(),comp); ansS-=Square_Triangle(res[0],p1,p4); ansS-=Square_Triangle(res[0],res[1],p4); ansS-=Square_Triangle(res[1],p3,p4); } if(p2.y>=p2.x+w) ansS-=abs(t2-t1)*abs(s2-s1); get_p(l2,res); len=(int)res.size(); if(len>1){ sort(res.begin(),res.end(),comp); ansS-=Square_Triangle(res[0],p1,p2); ansS-=Square_Triangle(res[0],res[1],p2); ansS-=Square_Triangle(res[1],p2,p3); } if(p4.y<=p4.x-w) ansS-=abs(t2-t1)*abs(s2-s1); ansS/=(abs(t2-t1)*abs(s2-s1)); printf(%.8f ,ansS); } return 0; }
                     
                    
                 
                
               
              
             
            
           
          
         
        
       
      
     
    
   
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇设计模式C++实现八:外观模式 下一篇hdu 1505 City Game(hdu1506的二..

评论

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