设为首页 加入收藏

TOP

概率 UVa11346
2015-07-20 17:15:08 来源: 作者: 【 】 浏览:2
Tags:概率 UVa11346

1.题目描述:点击打开链接

2.解题思路:根据对称性,只用算上半部分即可。面积恒为S的点构成一条双曲线,事先积分算出双曲线与矩形相交的面积(设矩形面积为m),即S+Sln(m/S),用矩形面积减去这部分面积,再除以m即可。注意边界情况特殊处理。

3.代码:

?

#define _CRT_SECURE_NO_WARNINGS 
#include
  
   
#include
   
     #include
    
      #include
     
       #include
      
        #include
       
         #include
        
          #include
          #include
          
            #include
           
             #include
            
              #include
             
               #include
              
                #include
               
                 #include
                
                  #include
                 
                   using namespace std; double a, b, S; int main() { //freopen("test.txt", "r", stdin); int t; cin >> t; while (t--) { cin >> a >> b >> S; double m = a*b; double ans; if (S >= m)ans = 0.0;//边界情况一 else if (S == 0)ans = 1.0;//边界情况二 else ans = (m - S - S*log(m / S)) / m; ans = 100.0*ans; printf("%.6lf%%\n", ans); } return 0; }
                 
                
               
              
             
            
           
          
        
       
      
     
    
   
  

?

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇LeetCode Search Insert Position 下一篇hdu4826---Labyrinth(简单dp)

评论

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

·Redis on AWS:Elast (2025-12-27 04:19:30)
·在 Spring Boot 项目 (2025-12-27 04:19:27)
·使用华为开发者空间 (2025-12-27 04:19:24)
·Getting Started wit (2025-12-27 03:49:24)
·Ubuntu 上最好用的中 (2025-12-27 03:49:20)