当前位置:网站首页>A. Round Down the Price
A. Round Down the Price
2022-07-27 02:30:00 【Felven】
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
At the store, the salespeople want to make all prices round.
In this problem, a number that is a power of 1010 is called a round number. For example, the numbers 100=1100=1, 101=10101=10, 102=100102=100 are round numbers, but 2020, 110110 and 256256 are not round numbers.
So, if an item is worth mm bourles (the value of the item is not greater than 109109), the sellers want to change its value to the nearest round number that is not greater than mm. They ask you: by how many bourles should you decrease the value of the item to make it worth exactly 10k10k bourles, where the value of kk — is the maximum possible (kk — any non-negative integer).
For example, let the item have a value of 178178-bourles. Then the new price of the item will be 100100, and the answer will be 178−100=78178−100=78.
Input
The first line of input data contains a single integer tt (1≤t≤1041≤t≤104) — the number of test cases .
Each test case is a string containing a single integer mm (1≤m≤1091≤m≤109) — the price of the item.
Output
For each test case, output on a separate line a single integer dd (0≤d<m0≤d<m) such that if you reduce the cost of the item by dd bourles, the cost of the item will be the maximal possible round number. More formally: m−d=10km−d=10k, where kk — the maximum possible non-negative integer.
Example
input
Copy
7 1 2 178 20 999999999 9000 987654321
output
Copy
0 1 78 10 899999999 8000 887654321
Note
In the example:
- 1−0=1001−0=100,
- 2−1=1002−1=100,
- 178−78=102178−78=102,
- 20−10=10120−10=101,
- 999999999−899999999=108999999999−899999999=108,
- 9000−8000=1039000−8000=103,
- 987654321−887654321=108987654321−887654321=108.
Note that in each test case, we get the maximum possible round number.
解题说明:此题是一道数学题,找到最接近某个数的10的幂,可以通过遍历每次乘以10,然后再求出差值。
#include<stdio.h>
int main()
{
long long n, t, m;
scanf("%lld", &n);
for (long long i = 0; i<n; i++)
{
scanf("%lld", &t);
m = 1;
while (m <= t)
{
m *= 10;
}
m /= 10;
printf("%lld\n", t - m);
}
return 0;
}边栏推荐
- 复盘:图像有哪些基本属性?关于图像的知识你知道哪些?图像的参数有哪些
- Programming implementation of eight queens
- connman介绍
- Record the problem of PHP program accessing system files incorrectly
- DNS record type and explanation of related terms
- 明汯投资裘慧明:长期优异超额的背后考验的是团队的投研能力和策略的完整性
- C语言入门实战(12):求自然常数e的值
- 开机启动流程及营救模式
- C # using sqlsugar updatable system to report invalid numbers, how to solve it? Ask for guidance!
- The new version of Alibaba Seata finally solves the idempotence, suspension and empty rollback problems of TCC mode
猜你喜欢
随机推荐
[untitled]
飞腾腾锐 D2000 荣获数字中国“十大硬核科技”奖
深圳家具展首日,金可儿展位三大看点全解锁!
Permutation and binary (Ji, DA) (day 84)
Csu18m91 is used as the master controller of the intelligent scale scheme
C语言力扣第43题之字符串相乘。优化竖式
Realization of regular hexagon map with two-dimensional array of unity
Insert pictures and videos in typera
The fifth strong network cup national network security challenge Title reappearance (with title attachment, detailed explanation)
C language introduction practice (12): find the value of natural constant e
【无标题】
Tool class of localdatetime sorted out by yourself
Plato farm has a new way of playing, and the arbitrage eplato has secured super high returns
Learning and understanding of four special data types of redis
Detailed tutorial of typera
Application, addition and deletion of B-tree
Prime factorization -- C (GCC) -- PTA
Duplicate disc: what are the basic attributes of an image? What do you know about images? What are the parameters of the image
明汯投资裘慧明:长期优异超额的背后考验的是团队的投研能力和策略的完整性
Day 27 of leetcode









