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 ...
随机推荐
- NYOJ 7-街区最短路径问题(曼哈顿距离)
街区最短路径问题 时间限制:3000 ms | 内存限制:65535 KB 难度:4 描述 一个街区有很多住户,街区的街道只能为东西.南北两种方向. 住户只可以沿着街道行走. 各个街道之间的间 ...
- package.json配置项
以下示例列举了常用的地方,一些不常用的可以查看文档:文档地址 { //该模块名字 "name":"test" , //版本 "version" ...
- VS2012 TFS切换账号登录
最近要做团队项目,用到的vs2012的tfs代码管理器(win7 +vs2012),切换账号的流程如下: 1.打开控制面板,进入用户账户 2.点击左侧的管理您的凭据,看到自己的TFS服务器的地址,然后 ...
- XX cannot be resolved to a type
http://www.cnblogs.com/xuxm2007/archive/2011/10/20/2219104.html 我是project->clean...即可 原理:将工程中的.cl ...
- java 笔试
单例设计模式: public class Singliton { //no new private Singliton (){ } static Singliton ins = null; publi ...
- NOPI导出Excel
NOPI导出Excel /// <summary> /// 导出的方法 Excel样式 /// </summary> /// <param name="ds&q ...
- B - 确定比赛名次
B - 确定比赛名次 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit S ...
- BZOJ 2434: [Noi2011]阿狸的打字机( AC自动机 + DFS序 + 树状数组 )
一个串a在b中出现, 那么a是b的某些前缀的后缀, 所以搞出AC自动机, 按fail反向建树, 然后查询(x, y)就是y的子树中有多少是x的前缀. 离线, 对AC自动机DFS一遍, 用dfs序+树状 ...
- leetcode Roman to Integer python
class Solution(object): def romanToInt(self, s): """ :type s: str :rtype: int "& ...
- 页面打开直接执行a点击事件
<script> window.onload = function(){ function autoclick(){ var url = document.getElementById(' ...