zoj1710
来源:互联网 发布:国培网络研修心得体会 编辑:程序博客网 时间:2024/04/29 20:54
#include <iostream>using namespace std;int main(){ double fHeightOfWell, fUpDistance, fDownDistance, fFatigueFactor; int nDay; while (1) { cin >> fHeightOfWell >> fUpDistance >> fDownDistance >> fFatigueFactor; if (fHeightOfWell == 0) { break; } else { double nFatigueDistance = (double)fUpDistance * fFatigueFactor / 100; double nHeightFromBottom = 0; nDay = 0; do { nDay++; nHeightFromBottom += fUpDistance; if (nHeightFromBottom > fHeightOfWell) { break; } else { nHeightFromBottom -= fDownDistance; fUpDistance -= nFatigueDistance; if (fUpDistance < 0) { fUpDistance = 0; } } } while (nHeightFromBottom >= 0); if (nHeightFromBottom > 0) { cout << "success on day " << nDay << endl; } else { cout << "failure on day " << nDay << endl; } } } return 0;}