码迷,mamicode.com
首页 > 其他好文 > 详细

codeforces水题100道 第十五题 Codeforces Round #262 (Div. 2) A. Vasya and Socks (brute force)

时间:2016-07-20 19:13:44      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:

题目链接:http://www.codeforces.com/problemset/problem/460/A
题意:Vasya每天用掉一双袜子,她妈妈每m天给他送一双袜子,Vasya一开始有n双袜子,请问第几天的时候Vasya会没有袜子穿?
C++代码:

技术分享
#include <iostream>
using namespace std;
int n, m;
int main()
{
    cin >> n >> m;
    int d = 0;
    while (n)
    {
        d ++;
        if (n)
            n --;
        else
            break;
        if (d % m == 0)
            n ++;
    }
    cout << d;
    return 0;
}
C++

 

codeforces水题100道 第十五题 Codeforces Round #262 (Div. 2) A. Vasya and Socks (brute force)

标签:

原文地址:http://www.cnblogs.com/moonlightpoet/p/5689207.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!