Advertisement
ostapdontstop

bibib

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