当前位置:网站首页>2022 Hangzhou Electric Multi school bowcraft
2022 Hangzhou Electric Multi school bowcraft
2022-07-26 04:01:00 【jangyi.】
1006 Bowcraft
The question :
The store offers a variety of upgrade books , Each upgrade book has a A \frac aA Aa The probability of being upgraded by one level , If the upgrade fails , Yes b B \frac bB Bb The probability of reducing the level to 0. Every book you buy , Will wait for the probability from [ 0 , A − 1 ] [0,A-1] [0,A−1] Generate numbers in a a a, from [ 0 , B − 1 ] [0,B-1] [0,B−1] Generate numbers in b b b. Question rises to... Under the optimal strategy k k k The expected number of books to buy .
analysis :
consider d p dp dp solve : d p [ i ] dp[i] dp[i] From 0 Step up to i i i The expected number of books to buy .
Suppose the current status of the book is ( a , b ) (a,b) (a,b), Then we can choose to use or not :
Make α = a A , β = b B \alpha=\frac aA, \beta=\frac bB α=Aa,β=Bb
1. If you use this book , Then rise to i + 1 i + 1 i+1 The expectation of level is :
Y = d p [ i + 1 ] = d p [ i ] + 1 + ( 1 − α ) ∗ ( 1 − β ) ∗ ( d p [ i + 1 ] − d p [ i ] ) + ( 1 − α ) ∗ β ∗ d p [ i + 1 ] ) Y=dp[i+1]=dp[i]+1+(1-\alpha)*(1-\beta)*(dp[i+1]-dp[i])+(1-\alpha)*\beta*dp[i+1]) Y=dp[i+1]=dp[i]+1+(1−α)∗(1−β)∗(dp[i+1]−dp[i])+(1−α)∗β∗dp[i+1])
Explain it. : Our expectation of successful promotion is d p [ i ] + 1 dp[i]+1 dp[i]+1, Because I want to buy a book , frequency +1; If we fail to upgrade but fail to reduce to 0 level , That is, the level remains unchanged : ( 1 − α ) ∗ ( 1 − β ) ∗ ( d p [ i + 1 ] − d p [ i ] ) (1-\alpha)*(1-\beta)*(dp[i+1]-dp[i]) (1−α)∗(1−β)∗(dp[i+1]−dp[i]), Ahead is the probability of occurrence , Well understood. , The following is the number of such events , That is, we are from i i i Step up to i + 1 i+1 i+1 The number of levels ; If we fail to upgrade and the level is reduced to 0: ( 1 − α ) ∗ β ∗ d p [ i + 1 ] ) (1-\alpha)*\beta*dp[i+1]) (1−α)∗β∗dp[i+1]), When it happens , We need to rise again to i + 1 i+1 i+1 level , Multiply to i + 1 i+1 i+1 Level expectations .
2. If not used :
X = d p [ i + 1 ] = d p [ i + 1 ] + 1 X=dp[i+1]=dp[i+1]+1 X=dp[i+1]=dp[i+1]+1
Explain it. : We don't use this book to rise to i + 1 i+1 i+1 level , But we still bought this book , frequency +1.
So we get the transfer equation :
d p [ i + 1 ] = 1 A B ∑ a , b m i n { X , Y } dp[i+1]=\frac {1}{AB}\sum_{a,b}min\{ X,Y\} dp[i+1]=AB1a,b∑min{ X,Y}
Because we need to adopt the best strategy to upgrade , So if we want to use this book to upgrade , that Need to meet Expectations for use ≤ \le ≤ Expectations not used ( Y ≤ X ) (Y\le X) (Y≤X)
Simplify to get d p [ i + 1 ] ≥ d p [ i ] ∗ α − α β + β α dp[i+1] \geq dp[i]*\frac{\alpha-\alpha \beta+\beta}{\alpha} dp[i+1]≥dp[i]∗αα−αβ+β
Observe the formula , Find out α − α β + β α \frac{\alpha-\alpha \beta+\beta}{\alpha} αα−αβ+β Smaller books are easier to use , That is, the book α − α β + β α \frac{\alpha-\alpha \beta+\beta}{\alpha} αα−αβ+β The smaller the better. .
Then we will all the books α − α β + β α \frac{\alpha-\alpha \beta+\beta}{\alpha} αα−αβ+β Sort , Enumeration takes the first t t t A small book , that
Simplification d p [ i + 1 ] = d p [ i ] + 1 + ( 1 − α ) ∗ ( 1 − β ) ∗ ( d p [ i + 1 ] − d p [ i ] ) + ( 1 − α ) ∗ β ∗ d p [ i + 1 ] ) dp[i+1]=dp[i]+1+(1-\alpha)*(1-\beta)*(dp[i+1]-dp[i])+(1-\alpha)*\beta*dp[i+1]) dp[i+1]=dp[i]+1+(1−α)∗(1−β)∗(dp[i+1]−dp[i])+(1−α)∗β∗dp[i+1]) have to :
d p [ i + 1 ] = A B + d p [ i ] ∗ ∑ front t Small α + β − α ∗ β t − ∑ front t Small 1 − α dp[i+1]=\frac{AB+dp[i]*\sum_{ front t Small }{\alpha+\beta-\alpha*\beta}}{t-\sum_{ front t Small }{1-\alpha}} dp[i+1]=t−∑ front t Small 1−αAB+dp[i]∗∑ front t Small α+β−α∗β.
Then enumerate recursion , Time complexity O ( k ∗ A ∗ B ) O(k*A*B) O(k∗A∗B)
code:
struct Node {
int a, b;
double val;
bool operator < (const Node &q) const {
return val < q.val;
}
}q[N];
void solve() {
int k, A, B;
cin >> k >> A >> B;
vector<double> f(k + 1, 0);
int tot = 0;
for(int i = 0; i < A; i++)
for(int j = 0; j < B; j++) {
tot++;
q[tot] = {
i, j};
if(i) q[tot].val = 1.0 * (A * j - i * j) / (i * B);
else q[tot].val = 1e18;
}
sort(q + 1, q + 1 + tot);
for(int i = 0; i < k; i++) {
f[i + 1] = 1e20;
double s1 = 0, s2 = 0;
for(int j = 1; j <= tot; j++) {
s1 += 1.0 * q[j].a / A + 1.0 * q[j].b / B - 1.0 * q[j].a / A * q[j].b / B;
s2 += 1 - 1.0 * q[j].a / A;
f[i + 1] = min(f[i + 1], 1.0 * (A * B + f[i] * s1) / (j - s2));
}
}
// for(int i = 0; i <= k; i++) D(f[i]);
printf("%.3lf\n", f[k]);
}
边栏推荐
- php中可以使用取绝对值函数 abs() 将负数转成正数
- 如何构建面向海量数据、高实时要求的企业级OLAP数据引擎?
- Dracoo master
- Analysis on the infectious problem of open source license
- [Reading Notes - > data analysis] Introduction to BDA textbook data analysis
- php 查找 session 存储文件位置的方法
- KBPC1510-ASEMI大芯片15A整流桥KBPC1510
- 【程序员必备】七夕表白攻略:”月遇从云,花遇和风,晚上的夜空很美“。(附源码合集)
- 苹果在其产品中拿掉了最后一颗Intel芯片
- 微信小程序实现音乐播放器(4)(使用pubsubjs实现页面间通信)
猜你喜欢

Dracoo Master天龙卡牌大师

通用测试用例写作规范

括号嵌套问题(建议收藏)

Go Plus Security:一款Build Web3不可或缺的安全生态基础设施

Experimental reproduction of image classification (reasoning only) based on caffe resnet-50 network

Bond network mode configuration

基于移位寄存器的同步FIFO

Multi merchant mall system function disassembly lecture 15 - platform side member label

Moco V2: further upgrade of Moco series

2021 CIKM |GF-VAE: A Flow-based Variational Autoencoder for Molecule Generation
随机推荐
Zkevm: summary of zkevm and L1 by Mina's CEO
深度学习之SuperViT
Basic principles of iptables
If you want to do a good job in software testing, you can first understand ast, SCA and penetration testing
Pits encountered by sdl2 OpenGL
Find my technology | the Internet of things asset tracking market has reached US $6.6 billion, and find my helps the market develop
Working ideas of stability and high availability guarantee
《opencv学习笔记》-- 边缘检测和canny算子、sobel算子、LapIacian 算子、scharr滤波器
测试工作不受重视?学长:你应该换位思考
Lua and go mixed call debugging records support cross platform (implemented through C and luajit)
1311_ Hardware design_ Summary of ICT concept, application, advantages and disadvantages
[Reading Notes - > data analysis] 01 introduction to data analysis
Realization of online shopping mall system based on JSP
深度学习之DAT
【读书笔记->数据分析】01 数据分析导论
Booking.com binke Shanghai noodles
[MCU simulation project] external interrupt 0 controls 8 LED flashes
Advanced content of MySQL -- three MySQL logs that must be understood binlog, redo log and undo log
Bracket nesting problem (recommended Collection)
Bond network mode configuration