Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <cmath>
- using namespace std;
- int main()
- {
- ifstream fin("input.txt");
- ofstream fout("output.txt");
- unsigned k, m, d, days = 0;
- fin >> k >> m >> d;
- long long books = m;
- double a = -4.9, b = k - 0.7, c = m * 0.2;
- double Di = b*b - 4*a*c;
- double x = -(b + sqrt(Di))/2/a;
- unsigned weeks = (unsigned) x;
- days = weeks * 7;
- books+= weeks * k*5;
- books-= (1 + days) * days/2;
- for (;;) {
- books-= days+1;
- if (d <= 5) books+= k;
- if (books >= 0) days++;
- else break;
- if (++d > 7) d = 1;
- }
- fout << days;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement