ostapdontstop

biba

Sep 10th, 2019
191
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <fstream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     ifstream fin("input.txt");
  8.     ofstream fout("output.txt");
  9.  
  10.     int k, m, d;
  11.     fin >> k >> m >> d;
  12.  
  13.     long long books = m, days = 0;
  14.  
  15.     double a = -4.9, b = k - 0.7, c = m * 0.2;
  16.     double Di = b*b - 4*a*c;
  17.     double x = -(b + sqrt(Di))/2/a;
  18.    
  19.     long long weeks = (long long) x;
  20.  
  21.     days = weeks * 7;  
  22.     books+= weeks * k*5;
  23.     books-= (1 + days) * days/2;
  24.  
  25.     for (;;) {
  26.  
  27.         books-= days+1;
  28.         if (d <= 5) books+= k;
  29.  
  30.         if (books >= 0) days++;
  31.         else break;
  32.  
  33.         if (++d > 7) d = 1;
  34.     }
  35.  
  36.     fout << days;
  37.     return 0;
  38. }
RAW Paste Data