#P9963. [THUPC 2024 初赛] 前缀和
[THUPC 2024 初赛] 前缀和
Problem Description
Xiaolan really likes random numbers.
They first choose a real number , and then generate random numbers . Each number is generated independently in the following way:
- equals with probability , equals with probability , equals with probability , and so on.
After generating these random numbers, Xiaoai computes the prefix sums of this sequence and obtains a sequence .
Given , Xiaolan wants to know: in expectation, how many fall within ?
Input Format
One line contains four numbers . It is guaranteed that , and has at most digits.
Output Format
Output a real number, the answer. You need to ensure that the absolute or relative error does not exceed .
3 0.5 1 2
1.000000
Hint
Sample #1 Explanation
With probability , and . In this case, only falls within .
With probability , and . In this case, fall within .
With probability , . In this case, only falls within .
So the expectation is .
Problem License
From the THUPC2024 (Tsinghua University Student Programming Contest and Collegiate Invitational) Preliminary.
The following “this repository” all refer to the official THUPC2024 Preliminary repository (https://github.com/ckw20/thupc2024_pre_public)
-
Any organization or individual may use or repost the problems in this repository free of charge.
-
When using the problems in this repository, any organization or individual should do so for free and publicly. It is strictly forbidden to profit from these problems or add special access restrictions to them.
-
If possible, please also provide ways to obtain resources such as testdata, standard solutions, and editorials when using the problems in this repository; otherwise, please attach the GitHub link of this repository.
Translated by ChatGPT 5