1580. Eeny Meeny

单点时限: 2.0 sec

内存限制: 256 MB

In darkest lived a tribe called the Eeny Meenys''. They got this name from their way of choosing a chief for a year. It appears that a newspaper reporter visited the tribe and managed to get across a few ideas of civilisation, but apparently came to an unfortunate end before finishing the job. Thus the tribe no longer had a permanent chief; the chief's term was exactly one year. At the end of that time, they ate the current chief, and chose another chief. Their method of choosing a chief was theEeny meeny miny mo’‘ method. All eligible tribal members (women were also eligible–one of the blessings of civilisation the tribe had adopted) stood in a circle, a starting place was chosen, and the chief medicine man (who was ineligible for chieftainship) went around counting out E',e’, n',y’, M',e’, e',n’, y',M’,i',n’, y',M’, o!',E’, e',n’, y',M’, e',e’, n',y’, M',i’, n',y’, M',o!’, .... At every o!', the person indicated was pushed out of the circle which then closed up and the count restarted with his neighbour (the one who would have beenE’ anyway). This process continued until only one was left–the new chief.

While the chance of glory for a year makes the job of chief highly attractive to tribal members, you (possessing a computer decades before they were invented) find the brevity of the glory unappealing. You have managed to find out that the count this year will start with Mxgobgwq (a very large person), so you would like to know where not to stand. You don’t know the direction, nor how many eligible people there are, but you can estimate the number (it is certainly less or equal than 1000000).

Write a program that will determine the `first’ (i.e. closest to Mxgobgwq) safe position to stand, regardless of the actual number of people and the direction of count (clockwise or anti-clockwise).

输入格式

Input will consist of a series of lines, each line containing the upper and lower estimates of the number of eligible people (both numbers inclusive). The file will be terminated by a line containing two zeroes (0 0).

输出格式

Output will consist of a series of lines, one for each line of the input. Each line will consist of a single number giving the number of the position closest to Mxgobgwq that will not be chosen as chief for any number in the given range and for either direction of elimination. If no position is safe then print “Better estimate needed”.

样例

Input
80 150
40 150
0 0
Output
1
Better estimate needed

0 人解决,2 人已尝试。

0 份提交通过,共有 3 份提交。

9.9 EMB 奖励。

创建: 17 年,3 月前.

修改: 7 年,2 月前.

最后提交: 3 年,12 月前.

来源: UVa

题目标签