Codeforces Round 176 (Div. 2)
B
Pipeline
Codeforces
1700
原题
← AC →
翻译中…

Vova, the Ultimate Thule new shaman, wants to build a pipeline. As there are exactly $*n*$ houses in Ultimate Thule, Vova wants the city to have exactly $*n*$ pipes, each such pipe should be connected to the water supply. A pipe can be connected to the water supply if there's water flowing out of it. Initially Vova has only one pipe with flowing water. Besides, Vova has several splitters.

翻译中…

A splitter is a construction that consists of one input (it can be connected to a water pipe) and $*x*$ output pipes. When a splitter is connected to a water pipe, water flows from each output pipe. You can assume that the output pipes are ordinary pipes. For example, you can connect water supply to such pipe if there's water flowing out from it. At most one splitter can be connected to any water pipe.

翻译中…

image The figure shows a $4$-output splitter

翻译中…

Vova has one splitter of each kind: with $2$, $3$, $4$, ..., $*k*$ outputs. Help Vova use the minimum number of splitters to build the required pipeline or otherwise state that it's impossible.

翻译中…

Vova needs the pipeline to have exactly $*n*$ pipes with flowing out water. Note that some of those pipes can be the output pipes of the splitters.

翻译中…

Input

翻译中…

The first line contains two space-separated integers $*n*$ and $*k*$ ($1 ≤ *n* ≤ 10^{18}$, $2 ≤ *k* ≤ 10^{9}$).

翻译中…

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

翻译中…

Output

翻译中…

Print a single integer — the minimum number of splitters needed to build the pipeline. If it is impossible to build a pipeline with the given splitters, print -1.

翻译中…

样例

Input #1
4 3
Output #1
2
InputCopy OutputCopy
Input #2
5 5
Output #2
1
InputCopy OutputCopy
Input #3
8 4
Output #3
-1
InputCopy OutputCopy
题目信息
题号
287B
时间限制
0.4 s
内存限制
256 MB
标签
二分
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。