CF287B.Pipeline

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Vova, the Ultimate Thule new shaman, wants to build a pipeline. As there are exactly nn houses in Ultimate Thule, Vova wants the city to have exactly nn 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 xx 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.

The figure shows a 44 -output splitterVova has one splitter of each kind: with 22 , 33 , 44 , ..., kk 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 nn pipes with flowing out water. Note that some of those pipes can be the output pipes of the splitters.

输入格式

The first line contains two space-separated integers nn and kk ( 1<=n<=10181<=n<=10^{18} , 2<=k<=1092<=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.

输出格式

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.

输入输出样例

  • 输入#1

    4 3
    

    输出#1

    2
    
  • 输入#2

    5 5
    

    输出#2

    1
    
  • 输入#3

    8 4
    

    输出#3

    -1
    
首页