Uva 11313 Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, t, i;
    cin >> t;
    while(t--)
    {
        cin >> n >> m;
        n = n - m;
        m--;
        int cnt = 1, f = 1;
        while(n > 0)
        {
            if(n >= m)
            {
                n = n - m;
                cnt++;
            }
            else
            {
                f = 0;
                break;
            }
        }
        if(f == 1)
            cout << cnt << "\n";
        else
            cout << "cannot do this" << "\n";
    }
    return 0;
}

Comments