Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>//bug
- #include <stdio.h>
- #include <algorithm>
- #include <iomanip>
- #include <math.h>
- using namespace std;
- double c, t;
- bool can(double x)
- {
- double val = c*log(x)/log(2)*x;
- if(val < t|| ceil(val) == int(val) && int(val) == t)
- return true;
- return false;
- }
- void bs()
- {
- double l = 1.0; double r = t;
- double result = 0;
- for(int i = 0; i < 100; i++){
- double mid = (l + r) / 2;
- if(can(mid)) l = mid;
- else r = mid;
- result = r;
- }
- cout << fixed << showpoint << setprecision(10) << result << endl;
- }
- int main()// c · n · log(n);zадано максимальное время работы t,
- //найдите такое наибольшее вещественозначное n, что алгоритм проработает не больше t.
- {
- #ifdef _DEBUG
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- cin >> c >> t;
- bs();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement