A municipal utility ingests hourly meter readings into a raw staging table where every value is written out as a 64-bit floating-point decimal string, even though every reading in the table is guaranteed to represent an exact whole number (its fractional part is always written as a single trailing 0 after the decimal point). Before the readings can move into the compact archival table, each one must have its data type changed from a floating-point representation to a native 32-bit signed integer.
Given n such readings, output each one recast to its plain integer value, in the same order they were given.
The first line contains a single integer n.
Each of the next n lines contains one reading, written as a decimal string of the form <optional -><digits>.0 (for example 182056.0 or -91.0), with no leading zeros in the integer part other than a single 0 for the value zero.
Print n lines. The i-th line must contain the i-th reading recast as a plain integer, with no decimal point and no leading +. If the recast value equals zero, print 0 with no sign, even if the input reading carried a leading - (e.g. -0.0 must print as 0).
.0 is dropped, every reading's integer value lies in the inclusive range [-2^31, 2^31 - 1].Example 1
Input
2 182056.0 -91.0
Expected
182056 -91
Explanation
`182056.0` has an integer part of 182056 and no sign, so it recasts to 182056. `-91.0` has a leading `-` and an integer part of 91, so it recasts to -91.
Example 2
Input
1 -0.0
Expected
0
Explanation
`-0.0` carries a leading `-`, but its integer value is exactly zero, and the archival format never stores a signed zero, so it recasts to `0` with no sign.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →