首页 技术 正文
技术 2022年11月15日
0 收藏 622 点赞 3,222 浏览 1359 个字

在两个传送带上分别三分两个点计算 三分套三分

# include <bits/stdc++.h>
# define IL inline
# define RG register
# define Fill(a, b) memset(a, b, sizeof(a))
# define Sqr(x) ((x) * (x))
using namespace std;
typedef long long ll;
const double EPS(1e-6), Div(0.382);IL ll Read(){
RG char c = getchar(); RG ll x = 0, z = 1;
for(; c < '0' || c > '9'; c = getchar()) z = c == '-' ? -1 : 1;
for(; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
return x * z;
}double ax, ay, bx, by, cx, cy, dx, dy, p, q, r;IL double Dis(RG double x1, RG double y1, RG double x2, RG double y2){
RG double t1 = sqrt(Sqr(ax - x1) + Sqr(ay - y1)) / p;
RG double t2 = sqrt(Sqr(x1 - x2) + Sqr(y1 - y2)) / r;
RG double t3 = sqrt(Sqr(x2 - dx) + Sqr(y2 - dy)) / q;
return t1 + t2 + t3;
}IL double Calc(RG double x, RG double y){
RG double x1 = cx, y1 = cy, x2 = dx, y2 = dy;
while(fabs(x2 - x1) > EPS || fabs(y2 - y1) > EPS){
RG double D1 = (x2 - x1) * Div, xmidl = x1 + D1, xmidr = x2 - D1;
RG double D2 = (y2 - y1) * Div, ymidl = y1 + D2, ymidr = y2 - D2;
RG double t1 = Dis(x, y, xmidl, ymidl), t2 = Dis(x, y, xmidr, ymidr);
if(t1 < t2) x2 = xmidr, y2 = ymidr;
else x1 = xmidl, y1 = ymidl;
}
return Dis(x, y, x1, y1);
}int main(RG int argc, RG char* argv[]){
ax = Read(); ay = Read(); bx = Read(); by = Read();
cx = Read(); cy = Read(); dx = Read(); dy = Read();
p = Read(); q = Read(); r = Read();
RG double x1 = ax, y1 = ay, x2 = bx, y2 = by;
while(fabs(x2 - x1) > EPS || fabs(y2 - y1) > EPS){
RG double D1 = (x2 - x1) * Div, xmidl = x1 + D1, xmidr = x2 - D1;
RG double D2 = (y2 - y1) * Div, ymidl = y1 + D2, ymidr = y2 - D2;
RG double t1 = Calc(xmidl, ymidl), t2 = Calc(xmidr, ymidr);
if(t1 < t2) x2 = xmidr, y2 = ymidr;
else x1 = xmidl, y1 = ymidl;
}
printf("%.2lf\n", Calc(x1, y1));
return 0;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,086
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,561
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,410
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,183
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,820
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,903