Parking Lot

Problem #339

Tags: c-1 puzzle simulation

Who solved this?

No translations... yet

This small problem I've found in some old magazine, regretfully I don't remember which, it was decades ago. Probably "Science and Life" for some 198x issue.

There is a Parking Lot, in a form of linear space of length W. Cars, when arrive, can park anywhere on it, taking exactly 1 unit of space. Of course they only can park in empty "gaps".

It is obvious that Parking Lot of length W can accommodate up to int(W) cars. However car drivers are careless and park they cars quite randomly, not necessarily aligning them to integer intervals.

For example, regard W = 2.5. In theory we can place 2 cars here. However if the first driver to arrive parks immediately in the center of it, then only two small gaps 0.75 units wide are left on both sides - so the second car won't fit.

So, how many cars on average can be parked on the lot of length W?

Input single value W - size of the parking lot (not exceeding 50).

Answer single value N - average number of cars which could be parked with precision no worse than 1%.

You need to login to get test data and submit solution.