Codeforces Round #262 (Div. 2) A. Vasya and Socks

A. Vasya and Socks
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Sample test(s)
Input
2 2
Output
3
Input
9 3
Output
13
Note

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.

题目意思:有n双袜子,每天穿一双,晚上扔掉,再输入m,当是m的倍数的时候再购进一双袜子,问一共可以维持几天?

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
using namespace std;
int main()
{
    int n,m;
    while(scanf("%d %d",&n ,&m)!=EOF)
    {
        int day=1;
        int k=0;
        while(n--)
        {
            if(day%m==0)
            {
                n++;
            }
            day++;
            k++;
        }
        printf("%d\n",k);
    }
    return 0;
}

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

→Judgement Protocol


Test: #1, time: 0 ms., memory: 0 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
2 2



Output
3



Answer
3



Checker Log
ok answer is '3'



Test: #2, time: 15 ms., memory: 0 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
9 3



Output
13



Answer
13



Checker Log
ok answer is '13'



Test: #3, time: 15 ms., memory: 0 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
1 2



Output
1



Answer
1



Checker Log
ok answer is '1'



Test: #4, time: 0 ms., memory: 0 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
2 3



Output
2



Answer
2



Checker Log
ok answer is '2'



Test: #5, time: 15 ms., memory: 0 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
1 99



Output
1



Answer
1



Checker Log
ok answer is '1'



Test: #6, time: 0 ms., memory: 4 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
4 4



Output
5



Answer
5



Checker Log
ok answer is '5'



Test: #7, time: 15 ms., memory: 0 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
10 2



Output
19



Answer
19



Checker Log
ok answer is '19'



Test: #8, time: 0 ms., memory: 0 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
10 9



Output
11



Answer
11



Checker Log
ok answer is '11'



Test: #9, time: 15 ms., memory: 0 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
100 100



Output
101



Answer
101



Checker Log
ok answer is '101'



Test: #10, time: 0 ms., memory: 4 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
2 27



Output
2



Answer
2



Checker Log
ok answer is '2'



Test: #11, time: 0 ms., memory: 0 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
99 100



Output
99



Answer
99



Checker Log
ok answer is '99'



Test: #12, time: 15 ms., memory: 0 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
99 2



Output
197



Answer
197



Checker Log
ok answer is '197'



Test: #13, time: 0 ms., memory: 0 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
100 3



Output
149



Answer
149



Checker Log
ok answer is '149'



Test: #14, time: 0 ms., memory: 0 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
98 3



Output
146



Answer
146



Checker Log
ok answer is '146'



Test: #15, time: 15 ms., memory: 0 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
4 4



Output
5



Answer
5



Checker Log
ok answer is '5'



Test: #16, time: 0 ms., memory: 0 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
100 2



Output
199



Answer
199



Checker Log
ok answer is '199'



Test: #17, time: 0 ms., memory: 0 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
62 4



Output
82



Answer
82



Checker Log
ok answer is '82'



Test: #18, time: 0 ms., memory: 0 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
99 10



Output
109



Answer
109



Checker Log
ok answer is '109'



Test: #19, time: 0 ms., memory: 4 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
100 5



Output
124



Answer
124



Checker Log
ok answer is '124'



Test: #20, time: 15 ms., memory: 0 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
80 80



Output
81



Answer
81



Checker Log
ok answer is '81'



Test: #21, time: 0 ms., memory: 0 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
95 16



Output
101



Answer
101



Checker Log
ok answer is '101'



Test: #22, time: 0 ms., memory: 0 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
75 16



Output
79



Answer
79



Checker Log
ok answer is '79'



Test: #23, time: 0 ms., memory: 0 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
99 74



Output
100



Answer
100



Checker Log
ok answer is '100'



Test: #24, time: 15 ms., memory: 0 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
20 21



Output
20



Answer
20



Checker Log
ok answer is '20'



Test: #25, time: 0 ms., memory: 4 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
52 96



Output
52



Answer
52



Checker Log
ok answer is '52'



Test: #26, time: 0 ms., memory: 0 KB, exit code: 0, checker exit code: 0, verdict: OK 



Input
24 5



Output
29



Answer
29



Checker Log
ok answer is '29'

 


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值