A10582 | Buy a Shovel
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Polycarp urgently needs a shovel! He comes to the shop and chooses an appropriate one. The shovel that Policarp chooses is sold for $k$ burles. Assume that there is an unlimited number of such shovels in the shop.
In his pocket Polycarp has an unlimited number of "10-burle coins" and exactly one coin of $r$ burles ( $1<=r<=9$ ).
What is the minimum number of shovels Polycarp has to buy so that he can pay for the purchase without any change? It is obvious that he can pay for 10 shovels without any change (by paying the requied amount of 10-burle coins and not using the coin of $r$ burles). But perhaps he can buy fewer shovels and pay without any change. Note that Polycarp should buy at least one shovel.
In his pocket Polycarp has an unlimited number of "10-burle coins" and exactly one coin of $r$ burles ( $1<=r<=9$ ).
What is the minimum number of shovels Polycarp has to buy so that he can pay for the purchase without any change? It is obvious that he can pay for 10 shovels without any change (by paying the requied amount of 10-burle coins and not using the coin of $r$ burles). But perhaps he can buy fewer shovels and pay without any change. Note that Polycarp should buy at least one shovel.
输入格式
The single line of input contains two integers $k$ and $r$ ( $1<=k<=1000$ , $1<=r<=9$ ) — the price of one shovel and the denomination of the coin in Polycarp's pocket that is different from "10-burle coins".
Remember that he has an unlimited number of coins in the denomination of 10, that is, Polycarp has enough money to buy any number of shovels.
Remember that he has an unlimited number of coins in the denomination of 10, that is, Polycarp has enough money to buy any number of shovels.
输出格式
Print the required minimum number of shovels Polycarp has to buy so that he can pay for them without any change.
输入输出样例
输入 #1
117 3
输出 #1
9
输入 #2
237 7
输出 #2
1
输入 #3
15 2
输出 #3
2
In the first example Polycarp can buy 9 shovels and pay $9·117=1053$ burles. Indeed, he can pay this sum by using 10-burle coins and one 3-burle coin. He can't buy fewer shovels without any change.
In the second example it is enough for Polycarp to buy one shovel.
In the third example Polycarp should buy two shovels and pay $2·15=30$ burles. It is obvious that he can pay this sum without any change.
In the second example it is enough for Polycarp to buy one shovel.
In the third example Polycarp should buy two shovels and pay $2·15=30$ burles. It is obvious that he can pay this sum without any change.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted