#T586. 骑车与走路
骑车与走路
Description
In Tsinghua University's campus, life would be very inconvenient without a bicycle when attending classes or handling errands. However, in reality, biking isn't always faster for every task because it involves finding a bike, unlocking it, parking it, and locking it again, which takes some time.
Assume the following:
- The time to find a bike, unlock it, and mount it is 27 seconds.
- The time to park and lock the bike is 23 seconds.
- Walking speed is 1.2 meters per second.
- Biking speed is 3.0 meters per second.
Determine whether biking or walking is faster for different distances.
- If biking is faster, output
"Bike". - If walking is faster, output
"Walk". - If they take the same time, output
"All".
Input Format
The input consists of a single line containing an integer representing the distance (in meters) for the errand.
Output Format
Output a single line:
"Bike"if biking is faster,"Walk"if walking is faster,"All"if they take the same time.
Example
Input:
120
Output:
Bike
Explanation:
- Biking time = 27 (prep) + 23 (parking) + (120 / 3.0) = 27 + 23 + 40 = 90 seconds.
- Walking time = 120 / 1.2 = 100 seconds.
Since biking is faster, the output is"Bike".
Constraints
- The input distance is a positive integer.
Solution Approach
- Calculate total biking time:
- Prep time (27s) + Parking time (23s) + (Distance / 3.0).
- Calculate walking time:
- Distance / 1.2.
- Compare the two times and output the result accordingly.
This problem requires careful handling of floating-point arithmetic to ensure accurate comparisons.
120
Bike
翻译结果
CodesOnline
(注:由于"CodesOnline"是一个专有名词或品牌名称,通常保持原样不翻译。如果上下文需要解释,可以补充说明其含义,例如:"CodesOnline(代码在线)"。此处根据要求直接保留原文格式。)
保留markdown格式的翻译示例:
## Source
CodesOnline
(若需进一步调整或补充说明请告知。)