#P1553. 数字反转(升级版)
数字反转(升级版)
Description
Given a number, reverse the digits in each place to obtain a new number.
Unlike NOIp2011 Junior Problem 1, this time the number can be a decimal, a fraction, a percentage, or an integer.
-
Integer reversal: reverse all digits.
-
Decimal reversal: reverse the digits of the integer part and the digits of the fractional part separately, without swapping the integer and fractional parts.
-
Fraction reversal: reverse the digits of the denominator, then reverse the digits of the numerator, without swapping the numerator and the denominator.
-
Percentage: the numerator is always an integer; only the digits are changed.
Input Format
A number .
Output Format
A number: the reversed form of .
5087462
2647805
600.084
6.48
700/27
7/72
8670%
768%
Hint
Constraints
- For of the testdata, is an integer with at most digits.
- For of the testdata, is a decimal, and both its integer part and fractional part have at most digits.
- For of the testdata, is a fraction, and both its numerator and denominator have at most digits.
- For of the testdata, is a percentage, and its numerator has at most digits.
Data Guarantees
- For integer reversal, both the original integer and the reversed integer satisfy the normal integer form: unless the original number is zero, the highest digit of both the original and the reversed number must not be zero.
- For decimal reversal, the part before the decimal point follows the same rule as integers. The part after the decimal point satisfies the normal decimal form, i.e., there are no extra trailing s (if the fractional part has nothing but , keep exactly zero. If trailing zeros appear after reversal, omit the extra s).
- For fraction reversal, the fraction is not reduced, and neither the numerator nor the denominator is a decimal. The input denominator is not . Rules related to integer reversal apply as above.
- For percentage reversal, see the rules related to integers.
There are no negative numbers in the testdata.
Translated by ChatGPT 5
京公网安备 11011102002149号