QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#146461 | #1781. Joint Jog Jam | mojospy | WA | 0ms | 3660kb | C++14 | 1.5kb | 2023-08-22 15:59:05 | 2023-08-22 15:59:06 |
Judging History
answer
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
const double N=1e-9;
double kx,ky,kex,key,ox,oy,oex,oey;
double add;
bool flag=false;
double dx,dy;
double dis(double x,double y,double xi,double yi){
return sqrt((x-xi)*(x-xi)+(y-yi)*(y-yi));
}
bool isvaild(double x,double y){
bool xi=(x>=min(ox,oex)&&x<=max(ox,oex));
bool yi=(y>=min(oy,oey)&&x<=max(oy,oey));
return xi&&yi;
}
double f(double x,double y){
double cur=dis(x,y,kx,ky);
double nextx,nexty;
if(flag){
nextx=ox,nexty=oy+(dy*cur);
}
else{
double addx=sqrt((cur*cur)/(add*add+1));
double addy=add*addx;
nextx=ox+dx*addx,nexty=oy+dy*addy;
}
if(!isvaild(nextx,nexty)){
nextx=oex,nexty=oey;
}
//cout<<"\xb2\xe2\xca\xd4"<<x<<" "<<y<<" "<<nextx<<" "<<nexty<<" "<<endl;
return dis(x,y,nextx,nexty);
}
int main(){
cin>>kx>>ky>>ox>>oy>>kex>>key>>oex>>oey;
double d1=dis(kx,ky,ox,oy);
double d2=dis(kex,key,oex,oey);
if(oex==ox) flag=true;
else add=(oey-oy)/(oex-ox);
cout<<add<<endl;
dy=(oey>oy?1:-1);
dx=(oex>ox?1:-1);
double lx=kx,ly=ky,rx=kex,ry=key;
while(dis(lx,ly,rx,ry)>N){
//cout<<"\xcf\xd6\xd4\xda:"<<lx<<" "<<ly<<" "<<rx<<" "<<ry<<" "<<dis(lx,ly,rx,ry)<<" "<<N<<endl;
//cout<<endl;
double xtemp=(rx-lx)/3;
double ytemp=(ry-ly)/3;
double Lx=lx+xtemp,Rx=rx-xtemp;
double Ly=ly+ytemp,Ry=ry-ytemp;
if(f(Lx,Ly)>f(Rx,Ry)) rx=Rx,ry=Ry;
else lx=Lx,ly=Ly;
}
cout<<fixed<<setprecision(8)<<max(f(lx,ly),max(d1,d2));
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3660kb
input:
6341 4789 1787 7737 3074 8627 347 3128
output:
3.20069 6138.03958932
result:
wrong answer 1st numbers differ - expected: '6138.0395893', found: '3.2006900', error = '0.9994785'