CF1068A.Birthday

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

伊万正在收集硬币。目前仅有 NN 种不同的可收集硬币,而伊万已拥有其中的 KK 种。他的生日即将来临,因此他全部 MM 位朋友决定送他一些硬币作为礼物。他们共同约定了以下三条规则:

  • 每人赠送的硬币数量必须相同;
  • 所有赠送给伊万的硬币必须互不相同;
  • 所有礼物中,至少有 LL 枚硬币是伊万当前收藏中尚未拥有的新硬币。

但朋友们并不知道伊万目前已拥有哪些硬币。他们希望尽量节省开支,因此想购买最少数量的硬币,使得无论伊万当前已拥有哪 KK 种硬币(即在所有可能的 KK 种硬币子集中),上述三条规则均能被满足。请你帮助他们求出这个最少的硬币总数;若无法满足所有规则,则说明这是不可能的。

输入格式

The only line of input contains 4 integers NN, MM, KK, LL (1≤K≤N≤10181 \le K \le N \le 10^{18}; 1≤M,  L≤10181 \le M, \,\, L \le 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.

输入仅有一行,包含 4 个整数 NN、MM、KK、LL(1≤K≤N≤10181 \le K \le N \le 10^{18};1≤M,  L≤10181 \le M, \,\, L \le 10^{18}),分别表示不同硬币的种类数、Ivan 的朋友数量、Ivan 的收藏规模,以及 Ivan 的收藏中必须为新硬币的数量。

输出格式

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

输出一个数字——满足所有条件时,一位朋友能赠送的最少硬币数量。如果无法满足全部三个条件,则输出 -1(不带引号)。

输入输出样例

  • 输入#1

    20 15 2 3

    输出#1

    1
  • 输入#2

    10 11 2 4

    输出#2

    -1

说明/提示

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.

在第一次测试中,每位朋友各提供一枚硬币就足够了,因为他将收到 15 枚不同的硬币,其中必有 13 枚是全新的。

在第二次测试中,伊万有 11 位朋友,但总共只有 10 种不同的硬币。因此,并非所有朋友都能向他提供互不相同的硬币。

输入解题思路,AI测评打分。不知道怎么写?

首页