A - Birthday

Ivan is collecting coins. There are only NN different collectible coins, Ivan has KK of them. He will be celebrating his birthday soon, so all his MM 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 LL 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 NN, MM, KK, LL (1≤K≤N≤10181≤K≤N≤1018; 1≤M,L≤10181≤M,L≤1018) — 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

20 15 2 3

Output

1

Input

10 11 2 4

Output

-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.

这道题充分的说明一个道理,做人要大方,不能太抠,可是主人公就碰到了很抠的朋友们,他们虽然会帮主人公收集硬币,但是他们不想帮太多,于是每次都是去帮助最小硬币数目

这道题的相信大家能看懂我前面的那些flag标记,疑惑的地方应该是m和m+1的区别,这点是因为如果如果能刚好送完全部的减去他已经拥有的等于咱们至少要送的话就除以m可以了,否则就是能少送就少送于是就用m+1。

#include<stdio.h>
#include<string.h>
#include<queue>
#include<algorithm>
using namespace std;
long long int N,M,K,L;
int main()
{
    while(~scanf("%lld%lld%lld%lld",&N,&M,&K,&L))
    {
        int flag=0,flag2=0;
        long long int num=N/M;
        if(L>N)
            flag=1;
        if(num*M-K<L)
            flag=1;
        if(M>N)
            flag=1;
        if(K>N-L)
            flag=1;
        if(flag)
            printf("-1\n");
        else
        {
            long long int ans;
            if((K+L)%M==0)
                ans=(K+L)/M;
            else
                ans=(K+L)/M+1;
            if(ans*M>N)
                printf("-1\n");
            else
                printf("%lld\n",ans);
        }

    }
    return 0;
}

 

猜你喜欢

转载自blog.csdn.net/aini875/article/details/83653734