CF732A.Buy a Shovel

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

波利卡普急需一把铲子!他来到商店,挑选了一把合适的铲子。他选中的这把铲子售价为 kk 卢布。假设商店中这种铲子的数量是无限的。

波利卡普口袋里有无限枚“10 卢布硬币”,以及恰好一枚 rr 卢布的硬币(其中 1≤r≤91 \le r \le 9)。

波利卡普最少需要购买多少把铲子,才能恰好付清货款而无需找零?显然,他总能购买 10 把铲子并恰好付清(仅使用若干枚 10 卢布硬币,不使用那枚 rr 卢布硬币)。但或许他能购买更少数量的铲子,并同样做到恰好付清。注意:波利卡普至少需购买一把铲子。

输入格式

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.

输入仅包含一行,有两个整数 kk 和 rr(1 ≤ k ≤ 10001 \le k \le 1000,1 ≤ r ≤ 91 \le r \le 9)——分别表示一把铲子的价格,以及 Polycarp 钱包中与“10 卢布硬币”面额不同的那枚硬币的面值。

注意:他拥有无限数量的面额为 10 的硬币,即 Polycarp 拥有足够的钱购买任意数量的铲子。

输出格式

Print the required minimum number of shovels Polycarp has to buy so that he can pay for them without any change.

输出 Polycarp 需要购买的铲子的最少数量,使得他能够恰好付清费用而无需找零。

输入输出样例

  • 输入#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.

在第一个例子中,Polycarp 可以购买 9 把铲子,支付 9⋅117=10539 \cdot 117 = 1053 布尔(burles)。事实上,他可以使用若干枚 10 布尔硬币和一枚 3 布尔硬币来恰好支付该金额。他无法在不找零的情况下购买更少数量的铲子。

在第二个例子中,Polycarp 只需购买一把铲子即可。

在第三个例子中,Polycarp 应购买两把铲子,支付 2⋅15=302 \cdot 15 = 30 布尔。显然,他可以恰好支付该金额而无需找零。

输入解题思路,AI测评打分。不知道怎么写?

首页