GYMDAY failing hidden test case?

My issue

First time asking for help, let me know if I’m doing this wrong.

I’ve designed what I believe to be an elegant solution, where I’m simply triggering a loop that will count how many trial lessons it will take to bring the (cost * (1 - discount * trial lessons taken)) down below the (budget - cost of trial lessons). Then I just compare the number of trial lessons with my budget to determine if I ended the loop because he ran out of money or because he was able to purchase it. It passes the example test case, but not the hidden test case. Can someone show me where I might be forgetting something? I’m sure there’s an edge case I haven’t considered.

My code

#include <iostream>
using namespace std;

int main() {
	int tests;
	cin >> tests;
	while (tests--)
	{
	    double D, C, B, i;
	    cin >> D >> C >> B;
	    for (i = 0; (B - i) < (C * (1 - ((D*i) / 100))) && i < B; i++);
	    if (i == B) cout << -1 << endl;
	    else cout << i << endl;
	}
	return 0;
}

Problem Link: International Gym Day Practice Coding Problem

double d, x, y;
cin>>d>>x>>y;
double o=x;
int steps = 0;

if (x<=y) {
    cout << "0\n";
    return;
}



while (x>y) {
    
    x = (o*(100-(steps+1)*d))/100;

    y--;
    steps++;

    if (y<0) {
        cout << "-1\n";
        return;
    }
}

cout<<steps<<endl;

I appreciate your response, but I do already have access to complete solutions through CodeChef, I’m mainly asking why my code is failing. If you can point out the difference that causes the issue, I would appreciate it!

your code will fail if you have 0 rs. remaining and membership cost is also 0

testcase where your code will fail
100 10 1

Oh that’s very interesting. So if you run out of money, you can still “purchase” a “free” membership. That makes sense. Thank you!

No Problem