日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

HOJ 13828 Funfair

發(fā)布時間:2023/12/10 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 HOJ 13828 Funfair 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

鏈接:http://acm.hnu.cn/online/?action=problem&type=show&id=13828

Problem description
We are going to a funfair where there are n games G1,...,Gn. We want to play k games out of the n games, and we can choose the order in which we play them—note that we cannot play any game more than once. We have to specify these k games and their order before starting any game.
At each point in time, we have some amount of money, which we use in playing the games. At the beginning, we have x0?Oshloobs of money. If before playing game Gi, we have x Oshloobs and we win in Gi, our money increases to x+Ai?for some Ai?? 0. If we have x Oshloobs before playing game Gi?and we lose in Gi, we lose Li?percent of x. The probability that we win game Gi?(independently of other games) is Pi?percents.
The goal is to play k of the games in such an order to maximize the expected amount of money we end up with after playing all k selected games in that order.

Input
There are multiple test cases in the input. The first line of each test case contains three space-separated integers n, k, and x0?(1 ? k ? n ? 100, 0 ? x0?? 106). Each of the next n lines specifies the properties of game Gi?with three space-separated integers Ai, Li, and Pi?(0 ? Ai,Li,Pi?? 100). The input terminates with a line containing 0 0 0 which should not be processed.

Output
For each test case, output a single line containing the maximum expected amount of our final money rounded to exactly two digits after the decimal point.

Sample Input
2 2 100 10 0 50 100 10 20 2 1 100 10 0 50 100 10 20 0 0 0
Sample Output
117.00 112.00

思路:dp;

場上想到了dp,但是排序處理的不好所以一直沒有A掉;現(xiàn)在改了一下…………

贏: (Ai + x) * Pi 輸: (1 - Pi)(1 - Li) * x 那我過完這一關(guān)剩余錢的期望是(1 - Li + LiPi) * x + Ai * Pi 假設(shè) c = (1 - Li + LiPi)d = Ai * Pi 即: cx + d 那么,在考慮先過A關(guān)還是B關(guān)的時候,有兩種可能性, 先過A關(guān):c2 * (c1*x+d1) + d2; 先過B關(guān):c1 * (c2*x+d2) + d1; 假設(shè)A大于B,c2 * (c1*x+d1) + d2 > c1 * (c2*x+d2) + d1
所以只需按此關(guān)系排序即可;然后開始dp;
轉(zhuǎn)移方程:

if(j==i) dp[i][j]=c*dp[i-1][j-1]+d;
else
{
dp[i][j]=max(dp[i-1][j],c*dp[i-1][j-1]+d);
}

具體詳見代碼:

#include<iostream> #include<cstring> #include<algorithm> #include<cstdio> using namespace std; const int maxn=105; struct node {double a,l,p,c,d;node(double _a=0.0,double _l=0.0,double _p=0.0):a(_a),l(_l),p(_p){c=1-l+l*p;d=a*p;}bool operator <(const node &r)const{return d*r.c+r.d>r.d*c+d;} }; node ga[maxn]; double dp[maxn][maxn];int main() {freopen("input.txt","r",stdin);int n,k;double x0;while(scanf("%d%d%lf",&n,&k,&x0),n){int nw=0,nl=0;for(int i=1;i<=n;i++){double ta,tl,tp;scanf("%lf%lf%lf",&ta,&tl,&tp);ga[i]=node(ta,tl/100.0,tp/100.0);}memset(dp,0,sizeof dp);sort(ga+1,ga+1+n);for(int i=0;i<=n;i++)dp[i][0]=x0;for(int i=1;i<=n;i++){int s=min(k,i);double c=ga[i].c,d=ga[i].d;for(int j=1;j<=s;j++){if(j==i) dp[i][j]=c*dp[i-1][j-1]+d;else{dp[i][j]=max(dp[i-1][j],c*dp[i-1][j-1]+d);}}}printf("%.2lf\n",dp[n][k]);}return 0; }

?

?

轉(zhuǎn)載于:https://www.cnblogs.com/MeowMeowMeow/p/7299208.html

總結(jié)

以上是生活随笔為你收集整理的HOJ 13828 Funfair的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 久久天堂影院 | 天天躁日日躁狠狠躁av | 日韩三级国产精品 | 免费欧美黄色片 | 日韩在线视频免费看 | 亚洲va韩国va欧美va | 国产精品一国产精品 | 三度诱惑免费版电影在线观看 | 成人国产精品久久久网站 | 在线中文字幕视频 | 三级成人在线 | 国产农村妇女aaaaa视频 | 日韩精品一区二区三区 | 五月综合激情日本mⅴ | 播放男人添女人下边视频 | 综合久色 | 丰满放荡岳乱妇91ww | 一区二区视频在线 | 一级特级片 | 色综合久久av | 亚洲精品一区二三区 | 大地资源二中文在线影视免费观看 | 丰满的女人性猛交 | 久天堂 | 国产精品久久综合青草亚洲AV | 国产日韩欧美在线 | 日日夜夜天天操 | 亚洲拍拍视频 | 97麻豆| 综合网婷婷 | av秋霞| 黄色高清在线观看 | 人人干超碰 | 肉色丝袜脚交一区二区 | 91香蕉国产在线观看软件 | 国产激情在线看 | 96人xxxxxxxxx69| 日韩精品一区二区三区国语自制 | 第一福利视频 | 波多野结衣二区 | 无码一区二区三区在线观看 | 精品国产99一区二区乱码综合 | 婷婷激情电影 | 黄色国产| 国产黄色视屏 | 美日韩丰满少妇在线观看 | 人人爽人人做 | 欧美成人一区二区视频 | 我们的2018在线观看免费高清 | 欧美激情一区二区三区蜜桃视频 | 三级a级片| 欧美成人午夜 | 国产v片| 91色视频在线观看 | 手机在线观看免费av | 中日毛片 | 国内av网 | 亚洲精品乱码久久久久久按摩观 | 青娱乐自拍视频 | 性高跟丝袜xxxxhd | 久久一区二区精品 | 国产午夜在线 | 日韩av男人的天堂 | 国产精品999久久久 在线青草 | 成全影视在线观看第8季 | 超碰超碰超碰超碰 | 丁香花国语版普通话 | 午夜激情在线播放 | 国产午夜激情 | 成年人在线观看视频 | 好吊色在线观看 | 亚洲图片激情小说 | 狠狠操在线 | 超碰av人人 | 日韩网站视频 | 成人亚洲网| 亚洲第一狼人区 | 男女超爽视频免费播放 | 成人av影视在线 | 波多野吉衣视频在线观看 | 美国黄色片网站 | 自拍偷拍免费 | www.黄在线| 日本欧美另类 | 日韩一区二区a片免费观看 伊人网综合在线 | 国产精品视频免费看 | 蜜臀视频一区二区 | 国产三级a | 亚洲深夜视频 | 99精品欧美 | 九七精品 | 91亚洲精品久久久蜜桃借种 | 欧美精品不卡 | 99精品视频免费观看 | 亚洲日日干 | 亚洲精品乱码久久久久久黑人 | 亚洲精品高清在线观看 | 日韩av在线网| 国产高清一区在线观看 |