102420: [AtCoder]ABC242 A - T-shirt

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $100$ points

Problem Statement

In a certain programming contest, T-shirts are awarded to participants according to the following rules.

  • All participants who ranked $A$-th or higher get a T-shirt.
  • Additionally, from the participants who ranked between $(A+1)$-th and $B$-th (inclusive), $C$ participants chosen uniformly at random get a T-shirt.

There were $1000$ participants in this contest, and all of them got different ranks.
Iroha-chan, who participated in this contest, ranked $X$-th.
Find the probability that she gets a T-shirt.

Constraints

  • All values in input are integers.
  • $1 \le A < B \le 1000$
  • $1 \le C \le B-A$
  • $1 \le X \le 1000$

Input

Input is given from Standard Input in the following format:

$A$ $B$ $C$ $X$

Output

Print the answer. Your output will be considered correct if the absolute or relative error from the judge's answer is at most $10^{−6}$.


Sample Input 1

30 500 20 103

Sample Output 1

0.042553191489

Iroha-chan ranked $103$-rd.
She will get a T-shirt if she is among the $20$ participants chosen uniformly at random from the $470$ participants who ranked between $31$-st and $500$-th, which happens with probability $\frac{20}{470}=0.04255319\dots$.


Sample Input 2

50 500 100 1

Sample Output 2

1.000000000000

Iroha-chan ranked $1$-st. This time, she is guaranteed to get a T-shirt.


Sample Input 3

1 2 1 1000

Sample Output 3

0.000000000000

Iroha-chan ranked $1000$-th. This time, she will never get a T-shirt.

Input

题意翻译

共 $1000$ 位选手参加比赛,前 $A$ 位选手必得奖,第 $A+1$ 到 $B$ 名随机选 $C$ 位选手得奖,在每个人排名都不同的情况下第 $X$ 名得到奖的概率是多少。 答案误差在 $10^{-6}$ 一下判为正确。 Translated by ShanCreeper.

Output

分数:$100$分

问题描述

在某次编程竞赛中,根据以下规则向参赛者颁发T恤。

  • 排名在第$A$名或以上的所有参赛者都将获得T恤。
  • 此外,从排名在第$(A+1)$名到第$B$名(含)的参赛者中,随机均匀选择$C$名参赛者获得T恤。

这次比赛有$1000$名参赛者,所有人都得到了不同的排名。
参加了这次比赛的いろは酱排名为第$X$名。
求她获得T恤的概率。

限制条件

  • 输入中的所有值都是整数。
  • $1 \le A < B \le 1000$
  • $1 \le C \le B-A$
  • $1 \le X \le 1000$

输入

输入数据从标准输入按以下格式给出:

$A$ $B$ $C$ $X$

输出

输出答案。 只要你的输出与评判答案之间的绝对误差或相对误差不超过$10^{−6}$,就会被认为是正确的。


样例输入1

30 500 20 103

样例输出1

0.042553191489

いろは酱排名为第$103$名。
如果她是排名在第$31$名到第$500$名之间的$470$名参赛者中被随机均匀选择的$20$名参赛者之一,那么她将获得T恤,这种情况发生的概率为$\frac{20}{470}=0.04255319\dots$。


样例输入2

50 500 100 1

样例输出2

1.000000000000

いろは酱排名为第$1$名。这次,她肯定会获得T恤。


样例输入3

1 2 1 1000

样例输出3

0.000000000000

いろは酱排名为第$1000$名。这次,她永远不会获得T恤。

加入题单

上一题 下一题 算法标签: