Sausage Sharing
Time limit1sMemory limit128 MB
Given N identical sausages split among M critics who must each receive an equal total amount, find the minimum number of cuts required.
- Level
Medium5 of 10
- Topics
- Number theory, Math, Greedy
- Solved
- No attempts yet
Problem
Sunyoung has prepared N identical sausages for M food critics. She wants to cut the sausages so that every critic receives exactly the same total amount of sausage.
Find the minimum number of cuts required.
Input
The first line contains two integers N and M, the number of sausages and the number of critics.
- 1 <= N, M <= 100
Output
Print the minimum number of cuts needed so that all critics can receive the same amount.