Tony's Log

Algorithms, Distributed System, Machine Learning

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

An iterative 'simulation' problem:

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    int t, n, c, m;
    cin >> t;
    while (t--)
    {
        cin >> n >> c >> m;
        int answer = 0;
        // Computer answer
        answer = n / c;
        int wrapper = answer;
        while (wrapper >= m)
        {
            wrapper -= m;
            wrapper++;
            answer++;
        }
        cout << answer << endl;
    }
    return 0;
}
posted on 2015-02-27 15:10  Tonix  阅读(146)  评论(0编辑  收藏  举报