No tags yet

No tag edit access

Time limit per test: 0.25 second(s)

Memory limit: 262144 kilobytes

Memory limit: 262144 kilobytes

input: standard

output: standard

output: standard

Goryinyich and vot decided to play the following funny game.

Initially some natural number is written on the board. Players move in turns, Goryinyich starts the game. In each turn, player wipes the board out and writes new number equal to the difference between erased number and number chosen by the player. Player may choose any number between one and sum of squares of digits of number that is written on the board. If minimal number is written on the board, the player who got the number in his turn is considered to win. Minimal number is the smallest possible number with a given length and given sum of squares of its digits.

Consider the example. Suppose that number 20 is written on the board. Goryinyich may subtract any number from 1 to 2

Goryinyich and vot agree on some natural number

Your task is to find expected gain of Goryinyich. Of course, you should realize that the players are not stupid (actually, they even also participate in computer programming contests from time to time), so everybody will do his best to maximize expected gain from the game.

sample input | sample output |

1 2 | Case #1: -1/1 Case #2: 0/1 |

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Apr/23/2019 06:13:50 (e2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|