benchmarks.wiki / Public workspace

Humanity's Last Code Exam / 2013_B / Hey, Better Bettor

Problem

Answer published by the source. Consult the official source to check your work against its answer.

platform

atcoder

question content

# Problem Description Recent recessions have not been kind to entertainment venues, including the gambling industry. Competition is fierce among casinos to attract players with lots of money, and some have begun to offer especially sweet deals. One casino is offering the following: you can gamble as much as you want at the casino. After you are finished, if you are down by any amount from when you started, the casino will refund x% x\% of your losses to you. Obviously, if you are ahead, you can keep all of your winnings. There is no time limit or money limit on this offer, but you can redeem it only once. For simplicity, assume all bets cost 1 dollar and pay out 2 dollars. Now suppose x x is 20. If you make 10 bets in total before quitting and only 3 of them pay out, your total loss is 3.2 dollars. If 6 of them pay out, you have gained 2 dollars. Given x x and the percentage probability p p of winning any individual bet, write a program to determine the maximum expected profit you can make from betting at this casino, using any gambling strategy. ## Input The input consists of a single test case. A test case consists of the refund percentage x x (0x<100)(0 \leq x < 100) followed by the winning probability percentage p p (0p<50)(0 \leq p < 50). Both x x and p p have at most two digits after the decimal point. ## Output Display the maximum expected profit with an absolute error of at most 103 10^{-3} . ### Sample Input 1
Plain-text mathematical notation (without MathML)
# Problem Description

Recent recessions have not been kind to entertainment venues, including the gambling industry. Competition is fierce among casinos to attract players with lots of money, and some have begun to offer especially sweet deals. One casino is offering the following: you can gamble as much as you want at the casino. After you are finished, if you are down by any amount from when you started, the casino will refund x% of your losses to you. Obviously, if you are ahead, you can keep all of your winnings. There is no time limit or money limit on this offer, but you can redeem it only once.

For simplicity, assume all bets cost 1 dollar and pay out 2 dollars. Now suppose x is 20. If you make 10 bets in total before quitting and only 3 of them pay out, your total loss is 3.2 dollars. If 6 of them pay out, you have gained 2 dollars.

Given x and the percentage probability p of winning any individual bet, write a program to determine the maximum expected profit you can make from betting at this casino, using any gambling strategy.

## Input

The input consists of a single test case. A test case consists of the refund percentage x (0≤x<100) followed by the winning probability percentage p (0≤p<50). Both x and p have at most two digits after the decimal point.

## Output

Display the maximum expected profit with an absolute error of at most 10^(−3).

### Sample Input 1
Original LaTeX notation
# Problem Description

Recent recessions have not been kind to entertainment venues, including the gambling industry. Competition is fierce among casinos to attract players with lots of money, and some have begun to offer especially sweet deals. One casino is offering the following: you can gamble as much as you want at the casino. After you are finished, if you are down by any amount from when you started, the casino will refund \( x\% \) of your losses to you. Obviously, if you are ahead, you can keep all of your winnings. There is no time limit or money limit on this offer, but you can redeem it only once.

For simplicity, assume all bets cost 1 dollar and pay out 2 dollars. Now suppose \( x \) is 20. If you make 10 bets in total before quitting and only 3 of them pay out, your total loss is 3.2 dollars. If 6 of them pay out, you have gained 2 dollars.

Given \( x \) and the percentage probability \( p \) of winning any individual bet, write a program to determine the maximum expected profit you can make from betting at this casino, using any gambling strategy.

## Input

The input consists of a single test case. A test case consists of the refund percentage \( x \) \((0 \leq x < 100)\) followed by the winning probability percentage \( p \) \((0 \leq p < 50)\). Both \( x \) and \( p \) have at most two digits after the decimal point.

## Output

Display the maximum expected profit with an absolute error of at most \( 10^{-3} \).

### Sample Input 1

Code

0 49.9

### Sample Output 1

Code

0.0

### Sample Input 2

Code

50 49.85

### Sample Output 2

Code

7.10178453

question title

Hey, Better Bettor

Discussion

Discussion

No discussion posts on this page yet. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.

Source and history

Official source

initial import