Advertisement
Spocoman

01. Black Flag

Nov 10th, 2023
874
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <iostream>
  2. #include<iomanip>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int days, dailyPlunder;
  8.     cin >> days >> dailyPlunder;
  9.  
  10.     double expectedPlunder, totalPlunder = 0;
  11.     cin >> expectedPlunder;
  12.  
  13.     for (int i = 1; i <= days; i++) {
  14.         totalPlunder += dailyPlunder;
  15.         if (i % 3 == 0) {
  16.             totalPlunder += dailyPlunder * 0.5;
  17.         }
  18.         if (i % 5 == 0) {
  19.             totalPlunder *= 0.7;
  20.         }
  21.     }
  22.  
  23.     if (totalPlunder >= expectedPlunder) {
  24.         cout << "Ahoy! " << fixed << setprecision(2) << totalPlunder << " plunder gained.\n";
  25.     }
  26.     else {
  27.         double percentage = totalPlunder / expectedPlunder * 100;
  28.         cout << "Collected only " << fixed << setprecision(2) << percentage << "% of the plunder.\n";
  29.     }
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement