Width of a Running Lane
National Olympiad — Municipal round (2011 season)
Submission name: ivet.cpp
Problem summary
An oval athletics track has eight adjacent lanes of equal width. Each lane is measured along a line 10 cm from its inner boundary. Given the measured lengths of lanes 1 and 8, find the width of one lane.
Input
The two real lengths L1 and L8, in the same unit.
Output
The lane width, rounded to three digits after the decimal point.
Constraints
0 < L1 < L8 ≤ 1000.
Worked example
An independently prepared example for this explanation.
Input
400 452.5
Output
1.194
Solution analysis
- An oval track consists of two straight sections and two semicircular bends. Moving to an outer lane does not change the straight-section lengths; it only increases the bend radii.
- The two semicircles together form one full circle. If each lane has width w, lane 8’s measuring curve is 7w farther out than lane 1’s. The common 10 cm offset cancels, giving L8−L1 = 2π·7w.
- Solve for w = (L8−L1)/(14π). For 400 and 452.5, the length difference is 52.5 and the width is approximately 1.193662, so the required output is 1.194.
Why it works
The straight lengths cancel in the subtraction. The combined circular bends increase by 2π times the radius difference, which is exactly seven lane widths. Dividing by 14π therefore recovers the unique width.
Watch out. There are seven gaps between lane 1 and lane 8, not eight. The 10 cm measurement offset is the same in both lanes and must not be added again. Use floating-point division and fixed three-decimal output.
Commented C++17 solution
An independently written complete program with standard headers.
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main(){
long double innerLength,outerLength;
cin>>innerLength>>outerLength;
const long double pi=acos(-1.0L);
// Seven lane widths separate the two measuring curves.
long double width=(outerLength-innerLength)/(14.0L*pi);
cout<<fixed<<setprecision(3)<<width<<'\n';
}