My issue
int d,x,y;cin>>d>>x>>y;
float k=(100.0*(y-x))/(100.0-x*d);
cout<<k<<endl;
if(k!=(int)k || k<0 || k>=y) cout<<-1<<endl;
else cout<<k<<endl;
this code is failing for tc: 2 50 50
the output should be 0
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;cin>>t;
while(t--){
int d,x,y;cin>>d>>x>>y;
float k=(100.0*(y-x))/(100.0-x*d);
cout<<k<<endl;
if(k!=(int)k || k<0 || k>=y) cout<<-1<<endl;
else cout<<k<<endl;
}
}
Problem Link: International Gym Day Practice Coding Problem