CF858B Which floor?

题目描述

题意 在Polycarp住的一栋建筑里,每一层有一些相等数量的公寓。不幸的是,Polycarp不记得在一层上有多少公寓了,但是他记得那些公寓是从1开始编号的,编号从低层到高层。那意味着,最开始的几个公寓在第一层,之后的几个公寓在第二层,以此类推。Polycarp不记得建筑里公寓的总数量,所以你可以将这栋建筑看为无限高(即有无限层)。注意楼层是从1开始编号的。 Polycarp记得几个公寓分别在哪几层。保证这些信息不会自我矛盾。(还有句话) 给你这些信息,你可以求出有n个公寓的建筑的确切层数吗?

输入格式

第一行包含两个整数n,m。$(1

输出格式

如果能确定唯一的层数,输出有n个公寓的建筑的层数。 如果不能确定,输出-1。 贡献者:Fowany

说明/提示

In the first example the 6-th flat is on the 2-nd floor, while the 7-th flat is on the 3-rd, so, the 6-th flat is the last on its floor and there are 3 flats on each floor. Thus, the 10-th flat is on the 4-th floor. In the second example there can be 3 or 4 flats on each floor, so we can't restore the floor for the 8-th flat.