At the store, the salespeople want to make all prices round.
In this problem, a number that is a power of 10 is called a round number. For example, the numbers 100=1, 101=10, 102=100 are round numbers, but 20, 110 and 256 are not round numbers.
So, if an item is worth m bourles (the value of the item is not greater than 109), the sellers want to change its value to the nearest round number that is not greater than m. They ask you: by how many bourles should you decrease the value of the item to make it worth exactly 10k bourles, where the value of k — is the maximum possible (k — any non-negative integer).
For example, let the item have a value of 178-bourles. Then the new price of the item will be 100, and the answer will be 178−100=78.
在商店裡,銷售人員想把所有的價格都變成約整數。
在這個問題中,10 次方的數稱為約整數。 例如,數字 100=1、101=10、102=100 是約整數,但 20、110 和 256 不是約整數。
因此,如果一件物品價值 m 元(物品的價值不大於 109),賣家希望將其價值更改為不大於 m 的最接近的約整數。 他們問你:你應該將物品的價值減少多少元,使其正好值 10k 元,其中 k 的值是要盡可能最大(k — 任何非負整數)。
例如,讓物品的值為 178-bourles。 那麼商品的新價格為 100,答案為 178−100=78。
The first line of input data contains a single integer t (1 ≤ t ≤ 104) — the number of test cases .
Each test case is a string containing a single integer m (1 ≤ m ≤ 109) — the price of the item.
輸入數據的第一行包含一個整數 t (1 ≤ t ≤ 104) — 測試用例的數量。
每個測試用例都是一個字符串,其中包含一個整數 m (1 ≤ m ≤ 109) — 商品的價格。
For each test case, output on a separate line a single integer d (0 ≤ d < m) such that if you reduce the cost of the item by d bourles, the cost of the item will be the maximal possible round number. More formally: m − d = 10k, where k — the maximum possible non-negative integer.
對於每個測試用例,在單獨的行上輸出一個整數 d (0 ≤ d < m),這樣如果您將項目的成本減少 d 元,則項目的成本將是最大可能的整數。 更正式地說:m − d = 10k,其中 k — 最大可能的非負整數。
7 1 2 178 20 999999999 9000 987654321
0 1 78 10 899999999 8000 887654321
In the example:
Note that in each test case, we get the maximum possible round number.
ID | User | Problem | Subject | Hit | Post Date |
348 |
1453222-0@g....
(S2B08)
|
a707 | 292 | 2022-11-09 10:25 |