fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int rh, nm, h, th, d;
  7.  
  8. while(cin >> rh >> nm) {
  9. d = 0;
  10. th = 0;
  11. while(nm--) {
  12. cin >> h;
  13. th += h;
  14. }
  15. if(th < rh) {
  16. while(th <= rh) {
  17. th += th;
  18. d++;
  19. }
  20. cout << "Project will finish within " << (d + 1) << " days." << "\n";
  21. } else {
  22. cout << "Project will finish within 1 day." << "\n";
  23. }
  24.  
  25. }
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 4528KB
stdin
53 2
8
9
stdout
Project will finish within 3 days.