BZOJ1857: [Scoi2010]传送带(三分套三分)
2018-06-17 20:41:51来源:未知 阅读 ()
Submit: 2005 Solved: 1091
[Submit][Status][Discuss]
Description
Input
Output
Sample Input
100 0 100 100
2 2 1
Sample Output
HINT
对于100%的数据,1<= Ax,Ay,Bx,By,Cx,Cy,Dx,Dy<=1000
1<=P,Q,R<=10
Source
Day2
#include<cstdio> #include<cmath> #include<algorithm> #define eps 1e-3 using namespace std; inline int read() { char c = getchar(); int x = 0, f = 1; while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();} while(c >= '0' && c <= '9') x = x * 10 + c - '0',c = getchar(); return x * f; } int Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, P, Q, R; double dis(double x, double y, double x2, double y2) { return sqrt((x2 - x) * (x2 -x) + (y2 - y) * (y2 - y)); } double check2(double x,double y,double x2,double y2) { return dis(Ax, Ay, x, y) / P + dis(x, y, x2, y2) / R + dis(x2, y2, Dx, Dy) / Q; } double check(double x, double y) { double lx = Cx, ly = Cy, rx = Dx, ry = Dy, a, b; while(abs(rx - lx) > eps || abs(ry - ly) > eps) { double wx1 = (lx * 2 + rx) / 3, wy1 = (ly * 2 + ry) / 3, wx2 = (lx + rx * 2) / 3, wy2 = (ly + ry * 2) / 3; a = check2(x, y, wx1, wy1); b = check2(x, y, wx2, wy2); if(a > b) lx = wx1, ly = wy1; else rx = wx2, ry = wy2; } return check2(x, y, lx, ly); } int main() { #ifdef WIN32 freopen("a.in","r",stdin); #endif Ax = read(), Ay = read(), Bx = read(), By = read(), Cx = read(), Cy = read(), Dx = read(), Dy = read(), P = read(), Q = read(), R = read(); double lx = Ax, ly = Ay, rx = Bx, ry = By; while(abs(rx - lx) > eps || abs(ry - ly) > eps) { double wx1 = (lx * 2 + rx) / 3, wy1 = (ly * 2 + ry) / 3, wx2 = (lx + rx * 2) / 3, wy2 = (ly + ry * 2) / 3; if(check(wx1, wy1) > check(wx2, wy2)) lx = wx1, ly = wy1; else rx = wx2, ry = wy2; } printf("%.2lf", check(lx, ly)); return 0; }
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- BZOJ1853: [Scoi2010]幸运数字(容斥原理) 2018-09-01
- BZOJ1854: [Scoi2010]游戏(二分图匹配) 2018-07-09
- bzoj1856 [ SCOI2010 ] -- 卡特兰数 2018-06-17
- bzoj1857 [ SCOI2010 ] -- 三分套三分 2018-06-17
- BZOJ 1854: [Scoi2010]游戏 2018-06-17
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash