欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1032A.Kitchen Utensils
Kitchen Utensils
The king's birthday dinner was attended by guests. The dinner was quite a success: every person has eaten several dishes (though the number of dishes was the same for every person) and every dish was served alongside with a new set of kitchen utensils.
All types of utensils in the kingdom are numbered from to . It is known that every set of utensils is the same and consist of different types of utensils, although every particular type may appear in the set at most once. For example, a valid set of utensils can be composed of one fork, one spoon and one knife.
After the dinner was over and the guests were dismissed, the king wondered what minimum possible number of utensils could be stolen. Unfortunately, the king has forgotten how many dishes have been served for every guest but he knows the list of all the utensils left after the dinner. Your task is to find the minimum possible number of stolen utensils.
Input
The first line contains two integer numbers and () — the number of kitchen utensils remaining after the dinner and the number of guests correspondingly.
The next line contains integers () — the types of the utensils remaining. Equal values stand for identical utensils while different values stand for different utensils.
Output
Output a single value — the minimum number of utensils that could be stolen by the guests.
Note
In the first example it is clear that at least one utensil of type has been stolen, since there are two guests and only one such utensil. But it is also possible that every person received only one dish and there were only six utensils in total, when every person got a set of utensils. Therefore, the answer is .
One can show that in the second example at least dishes should have been served for every guest, so the number of utensils should be at least : every set contains utensils and every one of the guests gets two such sets. Therefore, at least objects have been stolen. Please note that utensils of some types (for example, of types and in this example) may be not present in the set served for dishes.
Samples
5 2
1 2 2 1 3
1
10 3
1 3 3 1 3 5 5 5 5 100
14
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |