KUSAC - Kusac
题意翻译
给你 $n$ 个香肠,有 $m$ 位品尝者,你要切多少刀才能让每位品尝者都吃到同样分量的香肠。输出切多少刀。
题目描述
Mirko has given up on the difficult coach job and switched to food tasting instead. Having skipped
breakfast like a professional connoisseur, he is visiting a Croatian cured meat festival. The most
renowned cook at the festival, Marijan Bajs, has prepared N equal sausages which need to be
distributed to M tasters such that each taster gets a precisely equal amount. He will use his trusted knife
to cut them into pieces.
In order to elegantly divide the sausages, the number of cuts splitting individual sausages must be as
small as possible. For instance, if there are two sausages and six tasters (the first test case below), it is
sufficient to split each sausage into three equal parts, making a total of four cuts. On the other hand, if
there are three sausages and four tasters (the second test case below), one possibility is cutting off three
quarters of each sausage. Those larger parts will each go to one of the tasrers, while the fourth taster
will get the three smaller pieces (quarters) left over.
Mirko wants to try the famous sausages, so he volunteered to help Bajs. Help them calculate the
minimum total number of cuts needed to carry out the desired division.
输入输出格式
输入格式
The first and only line of input contains two positive integers, N and M (1
of sausages and tasters, respectively.
输出格式
The first and only line of output must contain the required minimum number of cuts.
输入输出样例
输入样例 #1
2 6
输出样例 #1
4
输入样例 #2
3 4
输出样例 #2
3