CF 460A - Vasya and Socks
原文
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.
翻譯結(jié)果
Vasya 有 n 雙襪子。 每天早上,瓦夏必須穿上一雙襪子才能去上學(xué)。 晚上回家后,瓦夏脫下用過(guò)的襪子并扔掉。 每個(gè)第m天(在數(shù)字為m、?2m、?3m、?...的日子)媽媽都會(huì)給Vasya買(mǎi)一雙襪子。 她在晚上很晚的時(shí)候做這件事,這樣瓦夏就無(wú)法在第二天之前穿上一雙新襪子。 連續(xù)多少天 Vasya 的襪子就會(huì)用完? 輸入 單行包含兩個(gè)整數(shù) n 和 m (1?≤?n?≤?100; 2?≤?m?≤?100),用空格分隔。 輸出 打印一個(gè)整數(shù)——問(wèn)題的答案。
--------------------------------
循環(huán)遍歷即可,只是每當(dāng)是m的倍數(shù)的時(shí)候n++一下,
下面是代碼: