欢迎光临散文网 会员登陆 & 注册

CF 460A - Vasya and Socks

2023-07-25 16:31 作者:您是打尖儿还是住店呢  | 我要投稿

原文

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, 2m, 3m, ...) 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? Input The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space. Output Print a single integer — the answer to the problem.

翻译结果

Vasya 有 n 双袜子。 每天早上,瓦夏必须穿上一双袜子才能去上学。 晚上回家后,瓦夏脱下用过的袜子并扔掉。 每个第m天(在数字为m、 2m、 3m、 ...的日子)妈妈都会给Vasya买一双袜子。 她在晚上很晚的时候做这件事,这样瓦夏就无法在第二天之前穿上一双新袜子。 连续多少天 Vasya 的袜子就会用完? 输入 单行包含两个整数 n 和 m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100),用空格分隔。 输出 打印一个整数——问题的答案。

--------------------------------

循环遍历即可,只是每当是m的倍数的时候n++一下,

下面是代码:



CF 460A - Vasya and Socks的评论 (共 条)

分享到微博请遵守国家法律