2131. Genie

单点时限: 2.0 sec

内存限制: 256 MB

Aladdin rubs the lamp and lo! comes out the genie. However, this is not the same genie that you have heard about in the Arabian Nights. The genie himself has a lamp with him. He rubs the lamp, and out come $N$ more genies, each of them also having a lamp a with themselves. However, each of the genies has a height only $\frac{1}{N+1}$ of the previous genie. Each genie rubs his lamp, and this continues, till the genies reach the smallest size, of height $1$. It is actually these small genies that do all the work for Aladdin. The peculiarity of each of these genies is that each of them has a height which is an integer.

Given the height of the initial genie and the number of genies of height $1$, you have the find the number of genies that are not doing any work (i.e. genies of height greater than $1$). You also have to determine the sum total of the heights of all the genies.

输入格式

The input consists of several test cases. Each case appears on a single line. A line has two integers, separated by a white space. The first integer is the height of the original genie and the second is the number of working genies (i.e. genies of height $1$). The input is terminated by the case 0 0. You do not have to process this case.

All numbers in the input will fit into 64-bit signed integers.

输出格式

For each input case, print the number of genies that are not working and the sum total of the height of all the genies, separated by a blank space. All the input and output numbers will fit into 64 bit signed integer representation.

样例

Input
216 125
5764801 1679616
0 0
Output
31 671
335923 30275911

2 人解决,14 人已尝试。

2 份提交通过,共有 91 份提交。

9.8 EMB 奖励。

创建: 15 年,11 月前.

修改: 6 年,3 月前.

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

来源: Codewars 2006

题目标签