CF460A.Vasya and Socks

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2_m_, 3_m_, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks?

瓦西娅有 nn 双袜子。每天早上,瓦西娅上学前必须穿上一双袜子。每天晚上回家后,瓦西娅会脱下当天穿过的袜子并将其丢弃。每过 mm 天(即在第 mm、2m2m、3m3m、…… 天),妈妈会给瓦西娅买一双新袜子。妈妈总是在深夜才买,因此瓦西娅无法在第二天之前穿上这双新袜子。问:瓦西娅能连续多少天都有袜子可穿,直到他彻底没有袜子可穿为止?

输入格式

The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space.

单行包含两个整数 nn 和 mm(1 ≤ n ≤ 1001 ≤ n ≤ 100;2 ≤ m ≤ 1002 ≤ m ≤ 100),以空格分隔。

输出格式

Print a single integer — the answer to the problem.

输出一个整数——该问题的答案。

输入输出样例

  • 输入#1

    2 2

    输出#1

    3
  • 输入#2

    9 3

    输出#2

    13

说明/提示

In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two.

In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day.

在第一个样例中,瓦西娅前两天穿着他最初拥有的袜子。然后在第三天,他穿上了第二天购买的袜子。

在第二个样例中,瓦西娅前九天穿着他最初拥有的袜子。接着,他用第三、第六和第九天购买的袜子各穿了三天。之后,他又用第十二天购买的袜子穿了一天。

输入解题思路,AI测评打分。不知道怎么写?

首页