CF #518 div2 A Birthday

51 篇文章 0 订阅

A. Birthday
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Ivan is collecting coins. There are only ?
different collectible coins, Ivan has ? of them. He will be celebrating his birthday soon, so all his ?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 ?
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 ?, ?, ?, ? (1≤?≤?≤1018; 1≤?,?≤10的18次方) — quantity of different coins, number of Ivan’s friends, size of Ivan’s collection and quantity of coins, that must be new in Ivan’s collection.
Output
Print one number — minimal number of coins one friend can gift to satisfy all the conditions. If it is impossible to satisfy all three conditions print “-1” (without quotes).
Examples
Input
Copy

20 15 2 3

Output
Copy

1

Input
Copy

10 11 2 4

Output
Copy

-1

Note

In the first test, one coin from each friend is enough, as he will be presented with 15 different coins and 13 of them will definitely be new.

In the second test, Ivan has 11 friends, but there are only 10 different coins. So all friends can’t present him different coins.
题意:一共 N 种硬币,我已经有其中 K 种,我的 M 个朋友每人送我等数量的硬币,且送来的每一枚硬币都不属于同一种,要求最后我收到手上的硬币至少有 L 种是我没有的,求每个人最少送几枚硬币。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m, l, k;
int main()
{
cin >> n >> m >> k >> l;
if(m > n)
{
cout<<-1<<endl;
return 0;
}
if(l + k <= m)
{
cout<<1<<endl;
return 0;
}
ll a;
if((l+k) % m == 0)
a = (k + 1)/ m;
else 
a = (k + 1)/ m + 1;
if(a * m > n)
cout << -1 << endl;
else 
cout<<a<<endl;

}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值