QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#201169#7331. The Catcher in the RyeQuanQiuTongAC ✓34ms4384kbC++141.5kb2023-10-05 12:53:592023-10-05 12:54:00

Judging History

你现在查看的是最新测评结果

  • [2023-10-05 12:54:00]
  • 评测
  • 测评结果:AC
  • 用时:34ms
  • 内存:4384kb
  • [2023-10-05 12:53:59]
  • 提交

answer

#include<cstdio>
#include<cmath>
#include<bits/stdc++.h>
#define read() ({int x,c,f=1;while((c=getchar())<48||57<c)if(c=='-')f=-1;for(x=c^48;47<(c=getchar())&&c<58;)x=x*10+(c^48);x*f; })

constexpr int N=2e5+2;
double sqr(int x){return x*x;
}
double x[3],v[3];
double f(double k){
	double sum=0;
	for(int i=0;i<3;++i)sum+=
		x[i]*sqrt(1/(1-sqr(k*v[i]))-1);
	return sum;
}
double foo(double theta){
	double s1=sin(theta)/v[0]*v[1], s2=sin(theta)/v[0]*v[2];
	double t0=tan(theta), t1=tan(asin(s1)), t2=tan(asin(s2));
	return x[0]*t0+x[1]*t1+x[2]*t2;
}
int solve0(){
	double h=read();
	x[0]=read(),x[1]=read(),x[2]=read(),v[0]=read(),v[1]=read(),v[2]=read();
	double l=0,r=4e5;
	
	while(r-l>10e-4){
		double mid=(l+r)/2;
		if(f(mid)<h)l=mid;
		else r=mid;
	}
	printf("%lf",(l+r)/2);
	return 0;
}
void solve(){
	double h=read();
	std::pair<int,int> p[3];
	for(int i=0;i<3;++i)p[i].second=read();
	for(int i=0;i<3;++i)p[i].first=read();
	std::sort(p,p+3,std::greater<std::pair<int,int>>());
	for(int i=0;i<3;++i)v[i]=p[i].first;
	for(int i=0;i<3;++i)x[i]=p[i].second;
	
	double l=0,r=acos(-1)/2,mid;
	
	while(r-l>10e-9){
		mid=(l+r)/2;
		if(foo(mid)<h)l=mid;
		else r=mid;
	}
	//printf("angle %lf %lf %lf %lf\n",mid,sin(mid),sin(mid)/v[0]*v[1],sin(mid)/v[0]*v[2]);
	double c0=cos(mid),
	th1=asin(sin(mid)/v[0]*v[1]),c1=cos(th1),
	th2=asin(sin(mid)/v[0]*v[2]),c2=cos(th2);
	printf("%lf\n",x[0]/c0/v[0]+x[1]/c1/v[1]+x[2]/c2/v[2]);
	return ;
}
int main(){
	for(int t=read();t--;)solve();
}
/*
2
10 3 4 3 1 1 1
21 5 12 4 4 3 4
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 4268kb

input:

2
10 3 4 3 1 1 1
21 5 12 4 4 3 4

output:

14.142136
8.750000

result:

ok 2 numbers

Test #2:

score: 0
Accepted
time: 34ms
memory: 4384kb

input:

10000
60522 14575 36426 79445 48772 90081 33447
90629 3497 47202 7775 94325 63982 4784
68417 2156 31932 35902 95728 78537 23857
30739 86918 29211 39679 38506 63340 86568
61868 60016 87940 96263 24593 1449 36991
90310 23355 77068 11431 8580 91757 49218
74934 94328 63676 29355 96221 99080 95922
31545 ...

output:

3.329501
3.127387
2.406279
3.230771
66.089548
4.221961
2.077557
13.350847
4.077427
7.162318
4.234664
1.470865
11.046489
0.970222
3.360088
5.661612
4.896624
3.037066
2.400917
20.357087
6.567582
6.027313
2.247234
1.739134
2.155288
5.372584
1.525176
6.474740
3.617352
3.513227
2.658739
3.841193
1.666107...

result:

ok 10000 numbers