logo AlgoBeat OnlineJudge
登录 注册

#217306. [ICPC 2017 Hong Kong R] Sets

内存限制:512 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

For a fixed number , we define as the set of integers . And for any , we define as a set containing all sums of two different numbers in .

For example, if , we have

Then, we sort each set respectively, and combine them in order into a sequence . In the above case, we have the sequence .

Now, given integers and , what is the -th number in sequence ?

输入格式

The input file contains several test cases, please handle it to the end of file.

For each case, there is only one line containing two integers and (). When , the input satisfies that .

输出格式

For each case, output one integer indicating the -th number of the sequence. Output if it does not exist.

样例

样例输入 1

4 6
2 20

样例输出 1

4
-1