bzoj 1857: [Scoi2010]传送带 三分
1857: [Scoi2010]传送带
Time Limit: 1 Sec Memory Limit: 64 MB
Submit: 934 Solved: 501
[Submit][Status][Discuss]
Description
Input
Output
Sample Input
100 0 100 100
2 2 1
Sample Output
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <bitset>
using namespace std;
#define pb(x) push_back(x)
#define ll long long
#define mk(x, y) make_pair(x, y)
#define lson l, m, rt<<1
#define mem(a) memset(a, 0, sizeof(a))
#define rson m+1, r, rt<<1|1
#define mem1(a) memset(a, -1, sizeof(a))
#define mem2(a) memset(a, 0x3f, sizeof(a))
#define rep(i, n, a) for(int i = a; i<n; i++)
#define fi first
#define se second
typedef pair<int, int> pll;
const double PI = acos(-1.0);
const double eps = 1e-;
const int mod = 1e9+;
const int inf = ;
const int dir[][] = { {-, }, {, }, {, -}, {, } };
double xa, xb, xc, xd, ya, yb, yc, yd, p, q, r;
double dis(double x1, double y1, double x2, double y2) {
return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
double ternary(double x, double y) {
double lx = xc, ly = yc, rx = xd, ry = yd;
while(fabs(rx-lx)>eps || fabs(ry-ly)>eps) {
double x1 = lx+(rx-lx)/, x2 = lx+(rx-lx)/*;
double y1 = ly+(ry-ly)/, y2 = ly+(ry-ly)/*;
double tmp1 = dis(x, y, x1, y1)/r+dis(x1, y1, xd, yd)/q+dis(x, y, xa, ya)/p;
double tmp2 = dis(x, y, x2, y2)/r+dis(x2, y2, xd, yd)/q+dis(x, y, xa, ya)/p;
if(tmp1>tmp2) {
lx = x1, ly = y1;
} else {
rx = x2, ry = y2;
}
}
return dis(x, y, lx, ly)/r+dis(lx, ly, xd, yd)/q+dis(x, y, xa, ya)/p;
}
double solve() {
double lx = xa, rx = xb, ly = ya, ry = yb;
while(fabs(rx-lx)>eps || fabs(ry-ly)>eps) {
double x1 = lx+(rx-lx)/, x2 = lx+(rx-lx)/*;
double y1 = ly+(ry-ly)/, y2 = ly+(ry-ly)/*;
double tmp1 = ternary(x1, y1), tmp2 = ternary(x2, y2);
if(tmp1>tmp2) {
lx = x1, ly = y1;
} else {
rx = x2, ry = y2;
}
}
return ternary(lx, ly); }
int main()
{
cin>>xa>>ya>>xb>>yb>>xc>>yc>>xd>>yd>>p>>q>>r;
double ans = solve();
printf("%.2f\n", ans);
return ;
}
bzoj 1857: [Scoi2010]传送带 三分的更多相关文章
- Bzoj 1857: [Scoi2010]传送带(三分套三分)
1857: [Scoi2010]传送带 Time Limit: 1 Sec Memory Limit: 64 MB Description 在一个2维平面上有两条传送带,每一条传送带可以看成是一条线段 ...
- BZOJ 1857: [Scoi2010]传送带
二次联通门 : BZOJ 1857: [Scoi2010]传送带 /* BZOJ 1857: [Scoi2010]传送带 三分套三分 可能是吧..dalao们都说明显是一个单峰函数 可是我证不出来.. ...
- BZOJ 1857: [Scoi2010]传送带(三分套三分)
Time Limit: 1 Sec Memory Limit: 64 MB Submit: 2549 Solved: 1370 [Submit][Status][Discuss] Descriptio ...
- 【BZOJ1857】[Scoi2010]传送带 三分套三分
[BZOJ1857][Scoi2010]传送带 Description 在一个2维平面上有两条传送带,每一条传送带可以看成是一条线段.两条传送带分别为线段AB和线段CD.lxhgww在AB上的移动速度 ...
- 【BZOJ】1857: [Scoi2010]传送带(三分)
http://www.lydsy.com/JudgeOnline/problem.php?id=1857 好神奇的三分.. 第一次写三分啊sad..看了题解啊题解QAQ 首先发现无论怎么走一定是在AB ...
- BZOJ 2131 [scoi2010] 传送带
@(BZOJ)[三分法] Description 在一个2维平面上有两条传送带,每一条传送带可以看成是一条线段. 两条传送带分别为线段AB和线段CD. lxhgww在AB上的移动速度为P,在CD上的移 ...
- 洛谷P2571 [SCOI2010]传送带 [三分]
题目传送门 传送带 题目描述 在一个2维平面上有两条传送带,每一条传送带可以看成是一条线段.两条传送带分别为线段AB和线段CD.lxhgww在AB上的移动速度为P,在CD上的移动速度为Q,在平面上的移 ...
- bzoj1857: [Scoi2010]传送带--三分套三分
三分套三分模板 貌似只要是单峰函数就可以用三分求解 #include<stdio.h> #include<string.h> #include<algorithm> ...
- [BZOJ1857][SCOI2010]传送带-[三分]
Description 传送门 Solution 三分套三分.代码简单但是证明苦兮兮.. 假如我们在AB上选了一个点G,求到该点到D的最小时间. 图中b与CD垂直.设目前从G到D所耗时间最短的路径为G ...
随机推荐
- Android开发学习之TypedArray类
在学习Android的开发中,学习Gallery视图显示图片的过程中,在设置图片适配器的时候,用到了此TypedArray类型,这次根据android SDK,一块把此类型弄清楚! android.c ...
- 仅仅需手动添加一行代码就可以让Laravel4执行在SAE (v. 1.0.0)
Github:https://github.com/chariothy/laravel4-sae (已更新至v1.1.0) laravel4-sae (v. 1.0.0) 仅仅需手动添加一行代码就可以 ...
- ASP连接sql server实例解析
1.首先确定自己的iis没有问题 2.其次确定自己sqlserver没有问题 然后在iis的文件夹wwwroot里,建立一个文件 名为testSqlServer.asp,编写代码例如以下就可以 < ...
- UML的基本图(一)
A class diagram shows a set of classes, interfaces, and collaborations and their relationships. T ...
- html基础标签-2-textarea文本域
textarea文本域 <!doctype html> <html lang='zh-cn'> <head> <meta charset='utf-8'> ...
- vs2012新建项目产生的问题
当用vs新建web项目时遇到
- access 语句错误
一直说是语句错误,一直没有找出来是什么错误,原来access的语句需要在字段上套一个[],这是最正确的写法,关键是动软生成的是我们一贯用的,和标准还是有些差别的,害了我好久都不知道是哪里的问题
- [C#参考]利用Socket连续发送数据
这个例子只是一个简单的连续发送数据,接收数据的DEMO.因为最近做一个项目,要求robot连续的通过Socket传回自己的当前的位置坐标,然后客户端接收到坐标信息,在本地绘制地图,实时显示robot的 ...
- nginx args
$args $content_length $content_type $document_root $document_uri $host $http_user_agent $http_cookie ...
- C++学习之嵌套类和局部类
C++学习之嵌套类和局部类 局部类 在一个函数体内定义的类称为局部类. 局部类中只能使用它的外围作用域中的对象和函数进行联系,因为外围作用域中的变量与该局部类的对象无关.在定义局部类时需要注意:局部类 ...