print1485. Floating formatting

printFloating formatting

Ограничения: время – 1s/2s, память – 64MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод copy
Послать решение Blockly Посылки Темы Где Обсудить (0)

Floating point numbers can be presented by a computer program in various formats, either exponential or fixed. For example, a number 1234.5 can be presented as "1234.5", "123.45e1", "0.12345e4", "12345e-1" and so on.
You program must find the shortest possible representation of a given floating point number. Representation is allowed to omit both leading and trailing zeros, but must preserve all the other digits.
Input file format
Input file contains a single floating point number. Note that it may be too long to be stored in built-in floating point types without loss of precision.
Output file format
Output file must contain a single string – the shortest representation of the input number. If there is more than one shortest representation, you must choose the one in fixed format, or, failing that, the one with the lowest absolute value of exponent.
Constraints
Input number contains from 1 to 1000 digits and is either 0 or in range from `10^{-2000}` to `10^2000`.
Both input and output numbers must contain at least one digit on each side of the decimal point (if the point is present) and must denote exponent with the lowercase letter 'e'.

Sample Input 1

001e-1

Sample Output 1

0.1

Sample Input 2

1e-002

Sample Output 2

0.01

Sample Input 3

0.001

Sample Output 3

1e-3

Sample Input 4

12000

Sample Output 4

12e3

Sample Input 5

12345e-4

Sample Output 5

1.2345

Sample Input 6

15e-10

Sample Output 6

1.5e-9
Source: NEERC ICPC, Far Eastern subregion, 2008
loading