E

来源:互联网 发布:linux多线程编程 编辑:程序博客网 时间:2024/06/09 18:58

Uva https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4966

Vjudge https://vjudge.net/problem/UVALive-6954


看不t 23333333333

上下界0 - 100 大神说随缘。。。

码着三分吧

注意精度 esp 其实最后输出7位就可以了


#include <algorithm>#include <iostream>#include <cstring>#include <iomanip>#include <cstdlib>#include <string>#include <cstdio>#include <cmath>#include <queue>#include <stack>#include <ctime>#include <map>using namespace std;#define sf scanf#define pf printf#define ll long long#define For(i,a,b) for(i=a;i<=b;i++)#define _For(i,a,b) for(i=b;i>=a;i--)#define Out(x) cout<<x<<endl#define Outdouble(x,a) cout<<fixed<<setprecision(a)<<1.0*x<<endl#define _Outdouble(x,a) cout<<fixed<<setprecision(a)<<1.0*x#define mset(arr,num) memset(arr,num,sizeof(arr))#define ok std::ios::sync_with_stdio(0)#pragma comment(linker, "/STACK:102400000,102400000")#pragma GCC optimize("O3")const ll inf = 1e12+10;  ///const double esp = 1e-7; ///const int NUM = 1e5+10;// #define debug#if defined (debug)---check---#endif/// ^_^  ^_^  ^_^  ^_^  ^_^  ^_^  ^_^  ^_^  ^_^  ^_^  ^_^  ^_^  ^_^ //////三分用来求单峰函数的极(最)值 ///二分是求单调函数的最值double two = sqrt(2);double p,s,v;int n;double cal(double x){return s*(1+1/x)/v + n*pow(log2(n),x*two)/p/1e9;}int main(){double l,r;   double mid,midmid;   while(cin>>n>>p>>s>>v)   {   l = 0,r = 100; ///   while(r - l > esp)   {   mid = (l+r)/2.0;   midmid = (mid + r)/2.0;   if(cal(mid) < cal(midmid))  ///求极小值 极大值下面边界相反   {   r = midmid;       }   else   {   l = mid;   }   }   _Outdouble(cal(l),14);   cout<<" ";   Outdouble(l,14);   }    return 0;}


1 0
原创粉丝点击