Codeforces A. Vasya and Socks

题目链接:http://codeforces.com/contest/460/problem/A

#include <iostream>

using namespace std;

int main()
{
    int m,n;
    cin>>m>>n;
    int sum;
    for(sum=1; m>0; sum++)
    {
        m--;
        if(sum % n == 0)
           m++;
    }
    sum--;
    cout<<sum<<endl;
    return 0;
}

你可能感兴趣的:(Codeforces A. Vasya and Socks)