fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4. int main() {
  5. int h, d, f, c = 0;
  6. double u;
  7. cin >> h >> u >> d >> f;
  8.  
  9. double y = u * f / 100;
  10. double x = 0;
  11.  
  12. while (x >= 0 && x <= h) {
  13. c++;
  14. x += u;
  15. if (x < 0 || x > h) {
  16. break;
  17. }
  18. x -= d;
  19. u -= y;
  20. if (u < 0) {
  21. u = 0;
  22. }
  23. }
  24.  
  25. if (x > h) {
  26. cout << "YES";
  27. } else {
  28. cout << "NO";
  29. }
  30.  
  31. cout << " " << c << endl;
  32. return 0;
  33. }
Success #stdin #stdout 0s 16064KB
stdin
6 3 1 10
stdout
YES 3