#P2555. [AHOI2002] 数的朗读
[AHOI2002] 数的朗读
Description
On a spring outing, Xiao Keke met Sealock, who had just returned to settle down. But Sealock was born overseas and only started learning Chinese after coming back. Reading numbers became a challenge for Sealock, so Xiao Keke decided to teach Sealock how to read numbers whose absolute value is less than 1 billion.
Xiao Keke knows the following rules for reading numbers in Chinese:
-
First read the sign, then read the integer part. A decimal point may appear after the integer part. If there is a fractional part, the decimal point must appear and be read out; after that, read the fractional part.
-
How to read the sign: (2.1) For a positive number, regardless of whether the plus sign "+" appears, the sign does not need to be read out. (2.2) For a negative number, the leftmost sign is "-", read as "Fu" (denoted by "F").
-
How to read the integer part: (3.1) If the integer part does not exist or the integer part is all zeros, read it directly as "ling" (denoted by "0"). (3.2) Otherwise, start reading from the leftmost nonzero digit of the integer part, and combine digits with the quantity units shi, bai, qian, wan, yi (denoted by "S", "B", "Q", "W", "Y" respectively) to spell out the integer part.
-
In the integer part: (4.1) Every nonzero digit must be read together with its corresponding quantity unit. (4.2) Each consecutive run of zeros may only be read as a single "ling" ("0"). However, if there is no nonzero digit on the left or on the right of this run of zeros (only considering the integer part), then this run of zeros should not be read.
-
If there is a fractional part, first read "dian" (denoted by "D"), then read each digit of the fractional part from left to right in order. Do not use shi, bai, qian, wan, yi or other quantity units in the fractional part. Every digit in the fractional part must be read out, and consecutive zeros must not be merged; they should be read separately.
-
If the number has a decimal point but no fractional part, the decimal point should not be read.
For example, -0020030004.567 should be read as F2Q03W04D567, and 000.89 should be read as 0D89.
Please write a program to help Xiao Keke read the given number correctly.
Input Format
A single line containing one number (no more than 50 characters), whose absolute value is less than 1 billion.
Output Format
Output a single line with the correct reading of the number.
000.89
0D89
-0020030004.567
F2Q03W04D567
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号