a707: Round Down the Price ( 價格約整數 )
Tags : 800 implementation math
Accepted rate : 23人/24人 ( 96% ) [非即時]
評分方式:
Tolerant

最近更新 : 2022-08-01 20:40

Content

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。

Input

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) — 商品的價格。

Output

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 — 最大可能的非負整數。

Sample Input #1
7
1
2
178
20
999999999
9000
987654321
Sample Output #1
0
1
78
10
899999999
8000
887654321
測資資訊:
記憶體限制: 64 MB
公開 測資點#0 (10%): 1.0s , <1K
公開 測資點#1 (10%): 1.0s , <1K
公開 測資點#2 (10%): 1.0s , <1K
公開 測資點#3 (10%): 1.0s , <1K
公開 測資點#4 (10%): 1.0s , <1K
公開 測資點#5 (10%): 1.0s , <1K
公開 測資點#6 (10%): 1.0s , <1M
公開 測資點#7 (10%): 1.0s , <1M
公開 測資點#8 (10%): 1.0s , <1M
公開 測資點#9 (10%): 1.0s , <1M
Hint :

In the example:

  • 1−0=100,
  • 2−1=100,
  • 178−78=102,
  • 20−10=101,
  • 999999999−899999999=108,
  • 9000−8000=103,
  • 987654321−887654321=108.

Note that in each test case, we get the maximum possible round number.

Tags:
800 implementation math
出處:
Codeforces Round #805 [管理者:
lamkinun@gma... (Kinda Lam)
]


ID User Problem Subject Hit Post Date
348
1453222-0@g.... (S2B08余汶憲)
a707
做对了
260 2022-11-09 10:25