当前位置:网站首页>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]);
}
边栏推荐
- Dtcloud the next day
- laravel8 实现接口鉴权封装使用JWT
- Data elements
- Opencv learning notes - edge detection and Canny operator, Sobel operator, lapiacian operator, ScHARR filter
- 基于SSM选课信息管理系统
- Go Plus Security:一款Build Web3不可或缺的安全生态基础设施
- 括号嵌套问题(建议收藏)
- E-commerce operator Xiaobai, how to get started quickly and learn data analysis?
- 《opencv学习笔记》-- 重映射
- 基于JSP实现网上商城系统
猜你喜欢

2021 CIKM |GF-VAE: A Flow-based Variational Autoencoder for Molecule Generation

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

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

(翻译)按钮位置约定能强化用户使用习惯

第十八章:2位a~b进制中均位奇观探索,指定整数的 3x+1 转化过程,指定区间验证角谷猜想,探求4份黑洞数,验证3位黑洞数

Connect external MySQL databases in istio Service Grid

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

Sentinel fusing and current limiting

Visio: how do Gantt charts merge cells? Solution: overwrite cells

A large factory developed and tested one, and strangled its neck with a mouse line
随机推荐
Synchronous FIFO based on shift register
Lua and go mixed call debugging records support cross platform (implemented through C and luajit)
Dat of deep learning
redux
想要做好软件测试,可以先了解AST、SCA和渗透测试
深度学习之DAT
Zkevm: summary of zkevm and L1 by Mina's CEO
[cloud native kubernetes] how to use configmap under kubernetes cluster
Data elements
Operator new, operator delete supplementary handouts
容器跑不动?网络可不背锅
[digital ic/fpga] Hot unique code detection
苹果在其产品中拿掉了最后一颗Intel芯片
2021 CIKM |GF-VAE: A Flow-based Variational Autoencoder for Molecule Generation
在 Istio 服务网格内连接外部 MySQL 数据库
Wechat applet realizes music player (5)
PHP 对象转换数组
Redis如何实现持久化?详细讲解AOF触发机制及其优缺点,带你快速掌握AOF
【云原生】谈谈老牌消息中间件ActiveMQ的理解
PHP installation spool supports dtls protocol