Advertisement
Spocoman

04. Clever Lily

Sep 7th, 2023
845
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include<string>
  3. #include<map>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     int age;
  9.     cin >> age;
  10.  
  11.     double mashinePrice, toyPrice;
  12.     cin >> mashinePrice >> toyPrice;
  13.  
  14.     double sum = 0;
  15.     int toyCount = 0;
  16.     int birthdayCash = 0;
  17.  
  18.     for (int i = 1; i <= age; i++) {
  19.         if (i % 2 == 0) {
  20.             birthdayCash += 10;
  21.             sum += birthdayCash - 1;
  22.         }
  23.         else {
  24.             toyCount++;
  25.         }
  26.     }
  27.  
  28.     sum += toyCount * toyPrice;
  29.  
  30.     cout.setf(ios::fixed);
  31.     cout.precision(2);
  32.  
  33.     if (sum >= mashinePrice) {
  34.         cout << "Yes! " << sum - mashinePrice << endl;
  35.     }
  36.     else {
  37.         cout << "No! " << mashinePrice - sum << endl;
  38.     }
  39.    
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement