Discount
Time Limit:1s | Memory limit:32M |
Accepted Submit:54 | Total Submit:117 |
Problem DescriptionInputThe first line contains t (1 ≤ t ≤ 20), the number of test cases followed. Each line contains two integers P and D(1 ≤ P ≤ 500, 1 ≤ D ≤ 99), the initial price and discount.OutPutFor each test case, print the amount of money Mr.Richman would like to pay.Sample Input5 50 30 104 17 500 4 498 6 40 5 Sample Output38 87 480 478 38 Original: 2009 NIT Cup National Invitation Contest Practice Session |
http://acm.fzu.edu.cn/problem.php?pid=1773
这一题是一种求一个数中是否含有某个数,这题里面求的是是否含有8这个数,比如448,458,380,如果没有,那就从个位逐渐加1,直到加最少的数就使这个数含有数字8。本程序的思想是这样的,用一个数组存放这个数的每一位:个位,十位,百位。然后一位一位的判断是否含有数字8,如果没有个位的数就加1,有点类似于高精度的加减法。