#t3. 英尺与英寸的转换
英尺与英寸的转换
Foot and Inch Conversion
Problem Description
The conversion between imperial and metric length units is as follows: 1 foot = 12 inches, and 1 foot = 0.3048 metres.
Given a length value measured in centimetres, convert it into imperial units and output the corresponding number of feet and inches.
Note: 1 metre = 100 centimetres, therefore 1 foot = 30.48 centimetres.
Input Format
The input gives a positive integer n, the length value, in centimetres.
Output Format
Output two integers on one line, the number of feet and the number of inches, separated by a space.
Sample Input
170
Sample Output
5 6
(Sample explanation: 170 cm = 170 / 30.48 ≈ 5.577 feet; taking the integer part gives 5 feet, and the remaining 0.577 feet × 12 ≈ 6.92 inches, rounded down to 6 inches.)
Constraints
1 ≤ n ≤ 10^5
Hint
- Dividing centimetres by 30.48 to get feet yields a real number — think about which part is the integer part of the quotient and which part is the fractional part.
- "Taking the integer part" can be done with a cast to (int), which simply discards the fractional part.
- How do you turn the remaining fraction into inches?
- Check against the sample: 170 → 5 6.
相关
在以下作业中: