设为首页 加入收藏

TOP

rockethon2015 C题 Second price auction 概率dp
2015-07-20 17:19:09 来源: 作者: 【 】 浏览:2
Tags:rockethon2015 Second price auction 概率

题意:n个人去竞拍一件商品,下面给出n个区间表示每个人出的价是区间中随机的一个数(概率均等)则第一名需要付的钱是第二名的竞拍价格(允许并列第一名)求支付的钱的期望。

?

?

/*********************************************************
  file name: C.cpp
  author : kereo
  create time:  2015年02月08日 星期日 22时26分08秒
*********************************************************/
#include
  
   
#include
   
     #include
    
      #include
     
       #include
      
        #include
        #include
        
          #include
         
           #include
          
            #include
           
             #include
            
              using namespace std; typedef long long ll; const int sigma_size=26; const int N=100+50; const int MAXN=10000+50; const int inf=0x3fffffff; const double eps=1e-8; const int mod=1000000000+7; #define L(x) (x<<1) #define R(x) (x<<1|1) #define PII pair
             
               #define mk(x,y) make_pair((x),(y)) int n; int l[MAXN],r[MAXN]; double solve1(int x){ //第一 >x int flag,tag; double ans=0; for(int i=1;i<=n;i++){ if(r[i]<=x) continue; flag=1,tag=0; for(int j=1;j<=n;j++){ if(i == j) continue; if(l[j]>x){ flag=0; break; } if(l[j]<=x && x<=r[j]) tag=1; } if(flag == 0 || tag == 0) continue; double res=(r[i]-max(x,l[i]-1))*1.0/(r[i]-l[i]+1); double ans1=1.0,ans2=1.0; //ans1为全部<=x的概率,ans2为全部
              
               =l[j] && x<=r[j]){ ans1*=(x-l[j]+1)*1.0/(r[j]-l[j]+1); ans2*=(x-l[j])*1.0/(r[j]-l[j]+1); } } ans+=(ans1-ans2)*res; } return ans; } double solve2(int x){ //第一 =x int flag=0; for(int i=1;i<=n;i++) if(x
               
                x ans+=solve2(i)*i; //第一人出价=x } printf(%.10f ,ans); } return 0; }
               
              
             
            
           
          
         
        
      
     
    
   
  


?

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇hdu 5172 RMQ 下一篇杭电ACM2092--整数解

评论

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

·MySQL 基础入门视频 (2025-12-26 23:20:22)
·小白入门:MySQL超详 (2025-12-26 23:20:19)
·关于 MySQL 数据库学 (2025-12-26 23:20:16)
·SOLVED: Ubuntu 24.0 (2025-12-26 22:51:53)
·Linux 常用命令最全 (2025-12-26 22:51:50)