#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 ss.

Output Format

A number: the reversed form of ss.

5087462
2647805
600.084
6.48
700/27
7/72
8670%
768%

Hint

Constraints

  • For 25%25\% of the testdata, ss is an integer with at most 2020 digits.
  • For 25%25\% of the testdata, ss is a decimal, and both its integer part and fractional part have at most 1010 digits.
  • For 25%25\% of the testdata, ss is a fraction, and both its numerator and denominator have at most 1010 digits.
  • For 25%25\% of the testdata, ss is a percentage, and its numerator has at most 1919 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 00s (if the fractional part has nothing but 00, keep exactly 11 zero. If trailing zeros appear after reversal, omit the extra 00s).
  • For fraction reversal, the fraction is not reduced, and neither the numerator nor the denominator is a decimal. The input denominator is not 00. 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