Counting ponorks
Time limit1sMemory limit128 MB
Count unit steps to walk a right-angled wall route where steps cut straight across corners and a final partial step of at least half a unit counts as one.
- Level
Medium7 of 10
- Topics
- Geometry, Simulation, Math
- Solved
- No attempts yet
Problem
The main part of the session was held in the Congress Finance Centre (KFC), so the building had to be protected properly. During the day, as anyone could see, the guard around it was more than thick enough. What matters here is a plainer night, once even most of the demonstrators have gone to sleep.
The building has to be watched at night as well. A few specially trained guards take that duty and circle the KFC all night along different routes. The most important route follows a narrow wall that runs around the whole building. It was laid out for strategic reasons, because the view of the surroundings from up there is very good. Covering the whole area takes several guards on this route, and there are always fewer people available than the work needs, so the police command has to find the smallest number of guards that still keeps the area around the building in sight. That starts with knowing how long the route is and how long a guard needs to walk it. Measuring the length is your task.

The police measure route length in police standard steps, ponork for short. The wall is a chain of straight sections joined at right angles, and every section is at least one ponork long. Police regulations say that a guard walking on the wall does not shorten the step when the direction changes. He steps over the corner instead, and the length of his step stays exactly one ponork. One step therefore runs in a straight line of exactly one ponork from one footfall to the next, cutting across the corner rather than following the bend of the wall. The wall has zero width. If the route cannot be walked so that the last step lands exactly on the end point of the wall, the leftover counts as a whole step only when it is at least half a ponork long. Determine the length of the route along the wall in ponorks. The picture matches the first case of the example input.
Input
The first line contains a positive integer , followed by cases. Each case begins with a line holding two values, and (, ), where is the length of the guard's step, the size of one ponork, and is the number of wall sections. The next lines hold the lengths of the individual sections, one number per line. Every length is an integer of at least .
Output
For each case print exactly one line in the form Strazny ujde X ponorku., where is the number of ponorks needed to walk the whole wall. Print the sentence exactly as shown and substitute only .