artemgf

Парк аттракционов

Apr 13th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <string>
  4. #include <algorithm>
  5. #include <vector>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     int namin[7], sc, all, how=1, prom, o[7];
  12.     vector <int> variants;
  13.     bool what = false;
  14.     o[1] = 10;
  15.     o[2] = 50;
  16.     o[3] = 100;
  17.     o[4] = 500;
  18.     o[5] = 1000;
  19.     o[6] = 5000;
  20.     cin >> namin[1] >> namin[2] >> namin[3] >> namin[4] >> namin[5] >> namin[6];
  21.  
  22.     cin >> sc;
  23.  
  24.     all = namin[1] * 10 + namin[2] * 50 + namin[3] * 100 + namin[4] * 500 + namin[5] * 1000 + namin[6] * 5000;
  25.  
  26.     variants.push_back(all / sc);
  27.     prom = all / sc-1;
  28.     while (what== false)
  29.     {
  30.         for (int i = 1; i <= 6; i++)
  31.         {
  32.             if (namin[i] != 0)
  33.                 if ((all - o[i]) >= prom*sc)
  34.                 {
  35.                     what = true;
  36.                     break;
  37.                 }
  38.                 else
  39.                 {
  40.                     variants.push_back(prom);
  41.                     prom--;
  42.                     how++;
  43.                     break;
  44.                 }
  45.  
  46.         }
  47.     }
  48.  
  49.     sort(variants.begin(), variants.end());
  50.     cout << how << endl;
  51.     for (int i = 0; i <variants.size(); i++)
  52.         cout << variants[i] << " ";
  53.  
  54.     _getch();
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment