Advertisement
DidiMilikina

04. Energy Loss

Oct 30th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int train_days;
  9.     int num_dancers;
  10.     cin >> train_days >> num_dancers;
  11.  
  12.     int energy_loss = 0;
  13.     int total_energy = 100 * num_dancers * train_days;
  14.  
  15.     for (int i = 1; i <= train_days; ++i)
  16.     {
  17.         int train_hours;
  18.         cin >> train_hours;
  19.  
  20.         int train = i % 2 == 0;
  21.         int hours = train_hours % 2 == 0;
  22.         int energy = 0;
  23.  
  24.         if (train && hours)
  25.         {
  26.             energy = 68;
  27.         }
  28.         else if (!train && hours)
  29.         {
  30.             energy = 49;
  31.         }
  32.         else if (train && !hours)
  33.         {
  34.             energy = 65;
  35.         }
  36.         else if (!train && !hours)
  37.         {
  38.             energy = 30;
  39.         }
  40.  
  41.         double current_energy_used = energy * num_dancers;
  42.         energy_loss += current_energy_used;
  43.     }
  44.  
  45.  
  46.     double left = total_energy - energy_loss;
  47.     double energy_each_person = left / num_dancers / train_days;
  48.  
  49.     if (energy_each_person > 50)
  50.     {
  51.         cout << "They feel good! Energy left: "
  52.             << fixed << setprecision(2) << energy_each_person
  53.             << endl;
  54.     }
  55.     else
  56.     {
  57.         cout << "They are wasted! Energy left: "
  58.             << fixed << setprecision(2) << energy_each_person
  59.             << endl;
  60.     }
  61.     return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement