【71.76%】【codeforces 732A】Buy a Shovel
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard 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.
【题解】
枚举要买j个Shovel就好;
j*price 或者j*price-r 如果%10==0则输出
(从1到10枚举)
#include <cstdio>
int k, r;
int main()
{
//freopen("F:\\rush.txt", "r", stdin);
scanf("%d%d", &k, &r);
for (int i = 1; i <= 10; i++)
{
int temp = i*k;
int temp1 = temp - r;
if ((temp % 10) == 0 || (temp1%10)==0)
{
printf("%d\n", i);
return 0;
}
}
return 0;
}
【71.76%】【codeforces 732A】Buy a Shovel的更多相关文章
- 【 BowWow and the Timetable CodeForces - 1204A 】【思维】
题目链接 可以发现 十进制4 对应 二进制100 十进制16 对应 二进制10000 十进制64 对应 二进制1000000 可以发现每多两个零,4的次幂就增加1. 用string读入题目给定的二进制 ...
- 【76.83%】【codeforces 554A】Kyoya and Photobooks
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【搜索】【并查集】Codeforces 691D Swaps in Permutation
题目链接: http://codeforces.com/problemset/problem/691/D 题目大意: 给一个1到N的排列,M个操作(1<=N,M<=106),每个操作可以交 ...
- 【中途相遇法】【STL】BAPC2014 K Key to Knowledge (Codeforces GYM 100526)
题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...
- 【链表】【模拟】Codeforces 706E Working routine
题目链接: http://codeforces.com/problemset/problem/706/E 题目大意: 给一个N*M的矩阵,Q个操作,每次把两个同样大小的子矩阵交换,子矩阵左上角坐标分别 ...
- 【数论】【扩展欧几里得】Codeforces 710D Two Arithmetic Progressions
题目链接: http://codeforces.com/problemset/problem/710/D 题目大意: 两个等差数列a1x+b1和a2x+b2,求L到R区间内重叠的点有几个. 0 < ...
- 【动态规划】【最短路】Codeforces 710E Generate a String
题目链接: http://codeforces.com/problemset/problem/710/E 题目大意: 问写N个字符的最小花费,写一个字符或者删除一个字符花费A,将当前的字符数量翻倍花费 ...
- 【离线】【深搜】【树】Codeforces 707D Persistent Bookcase
题目链接: http://codeforces.com/problemset/problem/707/D 题目大意: 一个N*M的书架,支持4种操作 1.把(x,y)变为有书. 2.把(x,y)变为没 ...
随机推荐
- Codeforces Round #460 (Div. 2) E. Congruence Equation (CRT+数论)
题目链接: http://codeforces.com/problemset/problem/919/E 题意: 让你求满足 \(na^n\equiv b \pmod p\) 的 \(n\) 的个数. ...
- Node知识总结
一. 伪装URL-SEO 伪URL重写 把一个动态页面的地址重写为静态页面的地址,为了方便网站的SEO优化 真实地址:http://item.jd.com/detail.php?id=12261336 ...
- 使用BeautifulSoup爬取“0daydown”站点的信息(2)——字符编码问题解决
上篇中的程序实现了抓取0daydown最新的10页信息.输出是直接输出到控制台里面.再次改进代码时我准备把它们写入到一个TXT文档中.这是问题就出来了. 最初我的代码例如以下: #-*- coding ...
- python opencv3 —— 改变颜色空间(color space)
OpenCV: Changing Colorspaces 1. 查看 opencv 支持的颜色空间转换 opencv 中色彩空间转换由一些定义的全局的宏给出,使用如下的代码,将它们调出: >&g ...
- Log4net.confager配置官方文档
http://logging.apache.org/log4net/release/config-examples.html
- log4j 2.x 版本的 properties 配置
#用于设置log4j2自身内部的信息输出,可以不设置,当设置成trace时,会看到log4j2内部各种详细输出status = debugdest = errname = PropertiesConf ...
- Eclipse高效开发插件汇总
以下是我整理的自己开发过程中的常用Eclipse插件,按字母排序: (1) AmaterasUML 介绍:Eclipse的UML插件,支持UML活动图,class图,sequen ...
- 数据库中暂时表,表变量和CTE使用优势极其差别
1 在写SQL时常常会用到暂时表,表变量和CTE,这三者在使用时各有优势: 1. 暂时表:分为局部暂时表和全局暂时表. 1.1局部暂时表,创建时以#开头,在系统数据库tempdb中存储. 在当前的链接 ...
- swift学习第十二天:类的属性定义
类的属性介绍 Swift中类的属性有多种 存储属性:存储实例的常量和变量 计算属性:通过某种方式计算出来的属性 类属性:与整个类自身相关的属性 存储属性 存储属性是最简单的属性,它作为类实例的一部分, ...
- 2016 Java程序员的年终总结(转)
2016 Java程序员的年终总结 技术积累 (1)代码规范 1.1.1.通常的模块分布:一般如果你要实现一个web 应用,你从后台将数据展示到前端页面,在一个比较大的公司,你少不了跟其他项目有交集( ...