• + 1 comment

    try out this

    for(int a0 = 0; a0 < t; a0++){
            int n;
            int c;
            int m;
            int num=0;
            cin >> n >> c >> m;
            int wrapper=0;
            num=n/c;
            wrapper=num;
            while(wrapper>=m)
            {
                num=num+(wrapper/m);
                wrapper=(wrapper/m)+(wrapper%m);
            }
            cout<<num<<endl;
    }