ÉèΪÊ×Ò³ ¼ÓÈëÊÕ²Ø

TOP

hdu 4089 Activation £¨¸ÅÂÊdp ÊÖ¶¯ÏûÔª£©(Ò»)
2015-07-20 17:34:46 À´Ô´: ×÷Õß: ¡¾´ó ÖРС¡¿ ä¯ÀÀ:3´Î
Tags£ºhdu 4089 Activation ¸ÅÂÊ ÊÖ¶¯

Activation

Time Limit: 20000/10000 MS ( Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1562 Accepted Submission(s): 592

Problem Description After 4 years' waiting, the game "Chinese Paladin 5" finally comes out. Tomato is a crazy fan, and luckily he got the first release. Now he is at home, ready to begin his journey.
But before starting the game, he must first activate the product on the official site. There are too many passionate fans that the activation server cannot deal with all the requests at the same time, so all the players must wait in queue. Each time, the server deals with the request of the first player in the queue, and the result may be one of the following, each has a probability:
1. Activation failed: This happens with the probability of p1. The queue remains unchanged and the server will try to deal with the same request the next time.
2. Connection failed: This happens with the probability of p2. Something just happened and the first player in queue lost his connection with the server. The server will then remove his request from the queue. After that, the player will immediately connect to the server again and starts queuing at the tail of the queue.
3. Activation succeeded: This happens with the probability of p3. Congratulations, the player will leave the queue and enjoy the game himself.
4. Service unavailable: This happens with the probability of p4. Something just happened and the server is down. The website must shutdown the server at once. All the requests that are still in the queue will never be dealt.
Tomato thinks it sucks if the server is down while he is still waiting in the queue and there are no more than K-1 guys before him. And he wants to know the probability that this ugly thing happens.
To make it clear, we say three things may happen to Tomato: he succeeded activating the game; the server is down while he is in the queue and there are no more than K-1 guys before him; the server is down while he is in the queue and there are at least K guys before him.
Now you are to calculate the probability of the second thing.
Input There are no more than 40 test cases. Each case in one line, contains three integers and four real numbers: N, M (1 <= M <= N <= 2000), K (K >= 1), p1, p2, p3, p4 (0 <= p1, p2, p3, p4 <= 1, p1 + p2 + p3 + p4 = 1), indicating there are N guys in the queue (the positions are numbered from 1 to N), and at the beginning Tomato is at the Mth position, with the probability p1, p2, p3, p4 mentioned above.
Output A real number in one line for each case, the probability that the ugly thing happens.
The answer should be rounded to 5 digits after the decimal point.
Sample Input
2 2 1 0.1 0.2 0.3 0.4
3 2 1 0.4 0.3 0.2 0.1
4 2 3 0.16 0.16 0.16 0.52

Sample Output
0.30427
0.23280
0.90343

Source 2011 Asia Beijing Regional Contest
ÌâÒ⣺ ÓÐn¸öÈËÅŶӵÈ×ÅÔÚ¹ÙÍøÉϼ¤»îÓÎÏ·¡£TomatoÅÅÔÚµÚm¸ö¡£
¶ÔÓÚ¶ÓÁÐÖеĵÚÒ»¸öÈË¡£ÓÐÒ»ÏÂÇé¿ö£º
1¡¢¼¤»îʧ°Ü£¬ÁôÔÚ¶ÓÁÐÖеȴýÏÂÒ»´Î¼¤»î£¨¸ÅÂÊΪp1)
2¡¢Ê§È¥Á¬½Ó£¬³ö¶ÓÁУ¬È»ºóÅÅÔÚ¶ÓÁеÄ×îºó£¨¸ÅÂÊΪp2£©
3¡¢¼¤»î³É¹¦£¬À뿪¶ÓÁУ¨¸ÅÂÊΪp3£©
4¡¢·þÎñÆ÷̱»¾£¬·þÎñÆ÷Í£Ö¹¼¤»î£¬ËùÓÐÈ˶¼ÎÞ·¨¼¤»îÁË¡£
Çó·þÎñÆ÷̱»¾Ê±TomatoÔÚ¶ÓÁÐÖеÄλÖÃ<=kµÄ¸ÅÂÊ¡£

˼·À´Ô´ÓÚ£ºµã»÷´ò¿ªÁ´½Ó
˼·£º dp[i][j]±íʾ»¹ÓÐi¸öÈË£¬ËûÔÚµÚj¸öλÖôﵽĿ±ê״̬µÄ¸ÅÂÊ¡£ if(j==1) dp[i][1]=dp[i][1]*p1+dp[i][i]*p2+p4;
if(j>=2&&j<=k) dp[i][j]=dp[i][j]*p1+dp[i][j-1]*p2+dp[i-1][j-1]*p3+p4;
if(j>k) dp[i][j]=dp[i][j]*p1+dp[i][j-1]*p2+dp[i-1][j-1]*p3;
»¯¼òһϣº
if(j==1) dp[i][1]=dp[i][i]*p2/(1-p1)+p4/(1-p1); £¨1£©
if(j>=2&&j<=k) dp[i][j]=dp[i][j-1]*p2/(1-p1)+dp[i-1][j-1]*p3/(1-p1)+p4/(1-p1);
if(j>k) dp[i][j]=dp[i][j-1]*p2/(1-p1)+dp[i-1][j-1]*p3/(1-p1);

ÔÚÇódp[i][j]µÄʱºòi-1µÄ״̬ȫ²¿ÖªµÀ£¬Ö»Óÿ¼ÂǵÚi²ã£¬ÒòΪdp[i][1]»áÍÆµ½dp[i][i]£¬ËùÒÔ»áÐγɻ·£¬ÐèÒªÊÖ¶¯»¯¼ò£¬×¢Òâi²»±ä£¬ËùÒÔÉæ¼°µ½µÄʽ×ÓÖ»ÓÐi¸ö£¬¿ÉÒÔµü´úÕÒ³ödp[i][i]Óëdp[i][1]µÄ¹ØÏµ£¬È»ºó´øÈ루1£©Ê½£¬½â³ödp[i][i]£¬È»ºó¾Í¿ÉÒÔÇódp[i][j]ÁË¡£»¹Òª×¢ÒâµÄÒ»µãÊÇp4ºÜСµÄʱºò¸ÅÂÊΪ0¡£
´úÂ룺
#include 
  
   
#include 
   
     #include 
    
      #include 
     
       #include 
      
        #include 
       
         #include 
         #include 
         
           #include 
          
            #include 
           
             #include 
            
              #define maxn 2005 #define MAXN 400005 #define mod 1000000007 #define INF 0x3f3f3f3f #define pi acos(-1.0) #define eps 1e-6 ty
Ê×Ò³ ÉÏÒ»Ò³ 1 2 ÏÂÒ»Ò³ βҳ 1/2/2
¡¾´ó ÖРС¡¿¡¾´òÓ¡¡¿ ¡¾·±Ìå¡¿¡¾Í¶¸å¡¿¡¾Êղء¿ ¡¾ÍƼö¡¿¡¾¾Ù±¨¡¿¡¾ÆÀÂÛ¡¿ ¡¾¹Ø±Õ¡¿ ¡¾·µ»Ø¶¥²¿¡¿
·ÖÏíµ½: 
ÉÏһƪ£ºhdu 4571 Travel in time £¨Floyd.. ÏÂһƪ£ºËæ±ã»­Ò»ÕÅ£¬°Â¹Å˹¶¼µÄÊÀ½ç¹Û ¼°..

ÆÀÂÛ

ÕÊ¡¡¡¡ºÅ: ÃÜÂë: (ÐÂÓû§×¢²á)
Ñé Ö¤ Âë:
±í¡¡¡¡Çé:
ÄÚ¡¡¡¡ÈÝ:

¡¤Linuxϵͳ¼ò½é (2025-12-25 21:55:25)
¡¤Linux°²×°MySQL¹ý³Ì (2025-12-25 21:55:22)
¡¤Linuxϵͳ°²×°½Ì³Ì£¨ (2025-12-25 21:55:20)
¡¤HTTP Åc HTTPS µÄ²î„ (2025-12-25 21:19:45)
¡¤ÍøÕ¾°²È«±ØÐ޿ΣºÍ¼ (2025-12-25 21:19:42)