Buy a Shovel
来源:互联网 发布:服务器端软件开发 编辑:程序博客网 时间:2024/06/10 03:42
Buy a Shovel
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.
Input
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.
Output
Print the required minimum number of shovels Polycarp has to buy so that he can pay for them without any change.
Example
Input
117 3
Output
9
Input
237 7
Output
1
Input
15 2
Output
2
Note
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.
#include<stdio.h>int main(){ int k,r; while(~scanf("%d%d",&k,&r)) { int n=1; while(n!=0) { if((n*k-r)%10==0) { printf("%d\n",n); break; } if((n*k)%10==0) { printf("%d\n",n); break; } n++; } } return 0;}
- A. Buy a Shovel
- A. Buy a Shovel
- Buy a Shovel
- codeforces732A A. Buy a Shovel
- 【71.76%】【codeforces 732A】Buy a Shovel
- Codeforces 732A.Buy a Shovel
- CodeForces 732A Buy a Shovel
- Codeforces 732A-Buy a Shovel
- CodeForces 732A 之 Buy a Shovel
- codeforces 732A Buy a Shovel(水题)
- Codeforces Round #377 (Div. 2) A. Buy a Shovel
- CodeForces-732A-Buy a Shovel(水题)
- CodeForces 732 A.Buy a Shovel(水~)
- codeforces——732A——Buy a Shovel
- CodeForces 732A Buy a Shovel(买铁铲不找零,掉分继续)
- Buy a Hat
- RabbitMQ shovel配置
- Codeforces899D Shovel Sale
- 2015年需要了解的前端框架和语言
- 杭电oj(Java版)2602 Bone Collector 01背包问题
- ITK4.11.1编译配置+VS2015+Cmake3.8.1
- python wget下载文件处理的一些问题
- FPGA状态机总结
- Buy a Shovel
- Windows Spark开发环境部署
- ==与===
- 比特币开发专题(交易平台基本原理和指南)
- 文件夹复制(拷贝)原理分析
- webpack2
- 反转的串
- malloc free 解析
- 使用MyBatis_Generator生成Dto、Dao、Mapping