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;
}