A. Buy a Shovel
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

Examples
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.

【题意】:口袋里面有无限枚 10 元和一枚 r 面值的硬币,问最少可以买多少把价值为 k 的铁铲。

【分析】:模拟。倍增k,直到为10的倍数(无限10元支付)或者减掉r后为10倍数。

【代码】:

#include <bits/stdc++.h>

using namespace std;
int main()
{
int r,k,sum;
while(cin>>k>>r)
{
sum=;
for(int i=;;i++)
{
sum=k*i;
if(sum%==||(sum-r)%==)
{
printf("%d\n",i);
break;
}
}
}
return ;
}

 

Codeforces Round #377 (Div. 2) A. Buy a Shovel【暴力/口袋里面有无限枚 10 元和一枚 r 面值的硬币,问最少可以买多少把价值为 k 的铁铲】的更多相关文章

  1. Codeforces Round #377 (Div. 2) D. Exams

    Codeforces Round #377 (Div. 2) D. Exams    题意:给你n个考试科目编号1~n以及他们所需要的复习时间ai;(复习时间不一定要连续的,可以分开,只要复习够ai天 ...

  2. Codeforces Round #297 (Div. 2)D. Arthur and Walls 暴力搜索

    Codeforces Round #297 (Div. 2)D. Arthur and Walls Time Limit: 2 Sec  Memory Limit: 512 MBSubmit: xxx ...

  3. Codeforces Round #377 (Div. 2) A B C D 水/贪心/贪心/二分

    A. Buy a Shovel time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  4. Codeforces Round #377 (Div. 2)部分题解A+B+C!

    A. Buy a Shovel 题意是很好懂的,一件商品单价为k,但他身上只有10块的若干和一张r块的:求最少买几件使得不需要找零.只需枚举数量判断总价最后一位是否为0或r即可. #include&l ...

  5. Codeforces Round #253 (Div. 1) A. Borya and Hanabi 暴力

    A. Borya and Hanabi Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/442/p ...

  6. Codeforces Round #336 (Div. 2)【A.思维,暴力,B.字符串,暴搜,前缀和,C.暴力,D,区间dp,E,字符串,数学】

    A. Saitama Destroys Hotel time limit per test:1 second memory limit per test:256 megabytes input:sta ...

  7. Codeforces Round #377 (Div. 2)

    #include <iostream> #include <stdio.h> #include <string.h> using namespace std; in ...

  8. Codeforces Round #377 (Div. 2)D(二分)

    题目链接:http://codeforces.com/contest/732/problem/D 题意: 在m天中要考k个课程, 数组a中有m个元素,表示第a[i]表示第i天可以进行哪门考试,若a[i ...

  9. Codeforces Round #377 (Div. 2) E. Sockets

    http://codeforces.com/contest/732/problem/E 题目说得很清楚,每个电脑去插一个插座,然后要刚好的,电脑的power和sockets的值相同才行. 如果不同,还 ...

随机推荐

  1. Windows 2003 IIS服务器配置环境(放.net开发的网站)

    配置IIS 安装.Net Framework3.5 安装SQL数据库 IIS的配置与安装步骤: 开始->管理工具->管理您的服务器->添加角色->(配置您的服务器向导)下一步- ...

  2. Pascal “内存病毒”(骗人的)

    Pascal内存病毒 Chaobs从互联网上获得 pascal病毒虽然说只用Ctrl+Pause Break就可以关闭,但是像有些程序一旦启动,不用等你找到那两个键,就自己运行结束关闭了.比如下面一个 ...

  3. Centos7中查看IP地址命令ifconfig无法识别如何处理

    问题描述: 在虚拟机中已安装好Centos7系统,查看IP地址使用命令ifconfig时,提示找不到此命令,使用ip addr命令则可查询当前系统的IP地址(如图1.2): 图1 图2 解决问题步骤: ...

  4. Python 黑魔法(持续收录)

    Python 黑魔法(持续收录) zip 对矩阵进行转置 a = [[1, 2, 3], [4, 5, 6]] print(list(map(list, zip(*a)))) zip 反转字典 a = ...

  5. linux的screen常用命令使用记录

    新建screen screen 或者 screen -S name - name用于指定一个screen的名字,默认系统随机 暂时退出当前screen ctrl + a + d - 同时按住这三个键即 ...

  6. Edu 0空投合约源码

    https://etherscan.io/address/0xa0872ee815b8dd0f6937386fd77134720d953581#code pragma solidity ^0.4.18 ...

  7. CentOS 6.3下安装Vsftp,虚拟用户

    CentOS 6.3下安装Vsftp,虚拟用户一.安装:1.安装Vsftpd服务相关部件:[root@linuxidc.com ~]# yum install vsftpd*Dependencies ...

  8. 软工实践Alpha冲刺(6/10)

    队名:起床一起肝活队 组长博客:博客链接 作业博客:班级博客本次作业的链接 组员情况 组员1(队长):白晨曦 过去两天完成了哪些任务 描述: 已经解决登录注册等基本功能的界面. 完成了主界面的基本布局 ...

  9. 冒泡排序 [组合数学+dp]

    题面 思路 一眼看过去以为NOI2018的题出出来了= =贼吓人 首先,对于这个难度,我们有一个比较明显的结论: 一个序列的难度,等于这个东西: $hard=max(\sum_{j=i+1}^n[a_ ...

  10. div样式

    DIV样式汇总 一.常用属性: 1.Height:设置DIV的高度. 2.Width:设置DIV的宽度. 例: <div style="width:200px;height:200px ...