Daffodil International University
Problem Link
//Please follow from main function
#include<bits/stdc++.h>
using namespace std;
int main()
{
double height_climb;
int cnt;
double h, u, d, f;
while(cin>>h>>u>>d>>f){
if(h==0 && u==0 && d==0 && f==0) break;
height_climb=0;
f=(u*(f/100.0));
cnt=0;
while(true){
cnt++;
if(u>0)height_climb+=u;
u-=f;
if(height_climb>h)break;
height_climb-=d;
if(height_climb<0)break;
}
if(height_climb>=0) cout<<"success on day "<<cnt<<endl;
else cout<<"failure on day "<<cnt<<endl;
}
return 0;
}
0 Comments