E - Euclidean TSP UVALive - 6954 (三分)
2017-02-23 21:37
330 查看
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位就可以了
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; }
相关文章推荐
- E - Euclidean TSP UVALive - 6954
- (转)三分问题 + UVALive 6954 Euclidean TSP
- UVALive 7509 三分
- UVALive 7509 三分
- UVALive 7509 三分
- UVALIVE 6958 I 求某TSP路径长度恰为定值+meet in middle + 折半
- uvalive 5742 TSP
- UVALive 7509 三分
- UVALive 7509 三分
- UVALive 7509 三分
- UVALive 6694 Toy Boxes (枚举 + 三分)
- UVALive 7509 三分
- UVALive 4986 Dome of Circus(三分、凸包、凸性函数)
- UVALive 7509 三分
- UVALive 7509 三分
- UVALive - 5009 Error Curves (三分)
- Error Curves(三分)uvalive 5009 求下凸 (最大值的最小值)
- UVALive 7509 三分
- G - Dome of Circus UVALive - 4986 (三分)
- uvalive 4986(三分查找)