#1001. 小猫分鱼
小猫分鱼
说明
海滩上有一堆鱼,<math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>N 只小猫来分。第一只小猫把这堆鱼平均分为 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>N 份,多了 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi><mo><</mo><mi>�</mi></mrow></semantics></math>i<N 个,这只小猫把多的 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>i 个扔入海中,拿走了一份。第二只小猫接着把剩下的鱼平均分成 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>N 份,又多了 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>i 个,小猫同样把多的 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>i 个扔入海中,拿走了一份。第三、第四、……,第 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>N 只小猫仍是最终剩下的鱼分成 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>N 份,扔掉多了的 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>i 个,并拿走一份。
编写程序,输入小猫的数量 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>N 以及每次扔到海里的鱼的数量 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>i,输出海滩上最少的鱼数,使得每只小猫都可吃到鱼。
例如:两只小猫来分鱼 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi><mo>=</mo><mn>2</mn></mrow></semantics></math>N=2,每次扔掉鱼的数量为 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi><mo>=</mo><mn>1</mn></mrow></semantics></math>i=1,为了每只小猫都可吃到鱼,可令第二只小猫需要拿走 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn></mrow></semantics></math>1 条鱼,则此时待分配的有 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>3</mn></mrow></semantics></math>3 条鱼。第一只小猫待分配的鱼有 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>3</mn><mo>∗</mo><mn>2</mn><mo>+</mo><mn>1</mn><mo>=</mo><mn>7</mn></mrow></semantics></math>3∗2+1=7 条。
输入格式
总共 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2</mn></mrow></semantics></math>2 行。第一行一个整数 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>N,第二行一个整数 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>i。
保证 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>0</mn><mo><</mo><mi>�</mi><mo><</mo><mn>10</mn></mrow></semantics></math>0<N<10;<math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi><mo><</mo><mi>�</mi></mrow></semantics></math>i<N 。
输出格式
一行一个整数,表示满足要求的海滩上最少的鱼数。
样例
2
1
7
提示
三只小猫来分鱼 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi><mo>=</mo><mn>3</mn></mrow></semantics></math>N=3,每次扔掉鱼的数量为 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi><mo>=</mo><mn>1</mn></mrow></semantics></math>i=1,为了每只小猫都可吃到鱼,可令第三只小猫需要拿走 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>3</mn></mrow></semantics></math>3 条鱼(拿走 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn></mrow></semantics></math>1 条和 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2</mn></mrow></semantics></math>2 条不满足要求),则此时待分配的有 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>10</mn></mrow></semantics></math>10 条鱼。第二只小猫待分配的鱼有 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>10</mn><mo>×</mo><mn>3</mn><mi mathvariant="normal">/</mi><mn>2</mn><mo>+</mo><mn>1</mn><mo>=</mo><mn>16</mn></mrow></semantics></math>10×3/2+1=16 条。第一只小猫待分配的鱼有 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>16</mn><mo>×</mo><mn>3</mn><mi mathvariant="normal">/</mi><mn>2</mn><mo>+</mo><mn>1</mn><mo>=</mo><mn>25</mn></mrow></semantics></math>16×3/2+1=25 条。