Advertisement
Spocoman

Workout

Sep 22nd, 2023
1,036
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int days;
  8.     cin >> days;
  9.  
  10.     double kilometers, percentage;
  11.     cin >> kilometers;
  12.     double totalKilometers = kilometers;
  13.     for (int i = 0; i < days; i++) {
  14.         cin >> percentage;
  15.         kilometers *= (100.0 + percentage) / 100;
  16.         totalKilometers += kilometers;
  17.     }
  18.  
  19.     if (totalKilometers < 1000) {
  20.         cout << "Sorry Mrs.Ivanova, you need to run " << 1000 - floor(totalKilometers) << " more kilometers\n";
  21.     }
  22.     else{
  23.         cout << "You've done a great job running " << ceil(totalKilometers) - 1000 << " more kilometers!\n";
  24.     }
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement