Codeforces Round #518 (Div. 2) A. Birthday 思维

博客讲述了Codeforces编程竞赛中的一道题目,问题涉及在限制条件下,如何确定每位朋友最少需要赠送多少不同的硬币给Ivan作为生日礼物,以确保至少有L个硬币是Ivan收藏中没有的。通过数学分析,得出了解决方案:当(k+L) % m == 0时,每个朋友需要赠送(k+L)/m枚硬币;否则,需要(k+L)/m + 1枚。若(k+L)大于硬币种类总数n,说明无法满足所有条件。
摘要由CSDN通过智能技术生成

A. Birthday

Ivan is collecting coins. There are only N different collectible coins, Ivan has K of them. He will be celebrating his birthday soon, so all his M freinds decided to gift him coins. They all agreed to three terms:

Everyone must gift as many coins as others.
All coins given to Ivan must be different.
Not less than L coins from gifts altogether, must be new in Ivan’s collection.
But his friends don’t know which coins have Ivan already got in his collection. They don’t want to spend money so they want to buy minimum quantity of coins, that satisfy all terms, irrespective of the Ivan’s collection. Help them to find this minimum number of coins or define it’s not possible to meet all the terms.

Input
The only line of input contains 4 integers N, M, K, L (1≤K≤N≤1018; 1≤M,L≤1018) — quantity of different coins, number of Ivan’s friends, size of Ivan’s collection and quantity of coins, that must be

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值