当前位置:网站首页>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]);
}
边栏推荐
- The second article, which is still unfinished, will be introduced again, and continue to explain oracledb_ Exporter monitors Oracle, a very low intrusive monitoring scheme.
- Asemi rectifier bridge gbu1510 parameters, gbu1510 specifications, gbu1510 package
- [MCU simulation project] external interrupt 0 controls 8 LED flashes
- [Reading Notes - > data analysis] Introduction to BDA textbook data analysis
- zk-SNARK:关于私钥、环签名、ZKKSP
- Connect external MySQL databases in istio Service Grid
- Aike AI frontier promotion (7.18)
- 深度学习之SuperViT
- FPS game reverse - box Perspective (matrix)
- 中国数据库 OceanBase 入选 Forrester Translytical 数据平台报告
猜你喜欢

Chapter 18: explore the wonders of the mean in the 2-bit a~b system, specify the 3x+1 conversion process of integers, specify an interval to verify the angular Valley conjecture, explore the number of

Basic line chart: the most intuitive presentation of data trends and changes

waf详解
![[Reading Notes - > data analysis] 01 introduction to data analysis](/img/50/622878bf649e77d5a4fa9732fa6f92.png)
[Reading Notes - > data analysis] 01 introduction to data analysis

Dat of deep learning

Data elements

ASEMI整流桥GBU1510参数,GBU1510规格,GBU1510封装

The convolution kernel is expanded to 51x51, and the new CNN architecture slak counterattacks the transformer

测试工作不受重视?学长:你应该换位思考

2021 CIKM |GF-VAE: A Flow-based Variational Autoencoder for Molecule Generation
随机推荐
Experimental reproduction of image classification (reasoning only) based on caffe resnet-50 network
Inventory the concept, classification and characteristics of cloud computing
[in depth study of 4g/5g/6g topic-42]: urllc-13 - in depth interpretation of 3GPP urllc related protocols, specifications and technical principles -7-low delay technology-1-subcarrier spacing expansio
Booking.com binke Shanghai noodles
ASEMI整流桥GBU1510参数,GBU1510规格,GBU1510封装
[MCU simulation project] external interrupt 0 controls 8 LED flashes
Find My技术|物联网资产跟踪市场规模达66亿美元,Find My助力市场发展
PHP method to find the location of session storage file
UFS Clk Gate介绍
Dracoo master
Chapter 18: explore the wonders of the mean in the 2-bit a~b system, specify the 3x+1 conversion process of integers, specify an interval to verify the angular Valley conjecture, explore the number of
Aike AI frontier promotion (7.18)
Bracket nesting problem (recommended Collection)
[深入研究4G/5G/6G专题-42]: URLLC-13-《3GPP URLLC相关协议、规范、技术原理深度解读》-7-低延时技术-1-子载波间隔扩展
Verilog implementation of key dithering elimination
基于SSM选课信息管理系统
zkEVM:MINA的CEO对zkEVM和L1相关内容的总结
Uncaught TypeError: $(...). Onmousenter is not a function JS error, solution:
redux
Data elements