301173: CF219B. Special Offer! Super Price 999 Bourles!
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Special Offer! Super Price 999 Bourles!
题意翻译
## 题目描述 Polycarpus是一个商人,他发现销售纸剪刀有一个很好的市场,所以他开始生产并销售纸剪刀。 Polycarpus会以p的原价售出,但为了吸引顾客,他会最多降价d元,他希望降价后,价格末尾的9数量最多。 ## 输入输出格式 ### 输入格式 输入两个数p和d,(1<=p<=10^18,1<=d<=p),尽量用cin和cout输入输出流,或%I64位输入 ### 输出格式 输出题意中所要求的价格,数首位不为零题目描述
Polycarpus is an amateur businessman. Recently he was surprised to find out that the market for paper scissors is completely free! Without further ado, Polycarpus decided to start producing and selling such scissors. Polycaprus calculated that the optimal celling price for such scissors would be $ p $ bourles. However, he read somewhere that customers are attracted by prices that say something like "Special Offer! Super price 999 bourles!". So Polycarpus decided to lower the price a little if it leads to the desired effect. Polycarpus agrees to lower the price by no more than $ d $ bourles so that the number of nines at the end of the resulting price is maximum. If there are several ways to do it, he chooses the maximum possible price. Note, Polycarpus counts only the trailing nines in a price.输入输出格式
输入格式
The first line contains two integers $ p $ and $ d $ ( $ 1<=p<=10^{18} $ ; $ 0<=d<p $ ) — the initial price of scissors and the maximum possible price reduction. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.
输出格式
Print the required price — the maximum price that ends with the largest number of nines and that is less than $ p $ by no more than $ d $ . The required number shouldn't have leading zeroes.
输入输出样例
输入样例 #1
1029 102
输出样例 #1
999
输入样例 #2
27191 17
输出样例 #2
27189