问题:Keiichi Tsuchiya the Drift King Gym - 102028D
参考博客:CodeForces GYM 102028 2018-2019 ACM-ICPC, Asia Jiaozuo Regional Contest
代码:
#include<bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
int main(){
int T;
cin>>T;
while(T--){
double a, b, r, d;
scanf("%lf %lf %lf %lf", &a, &b, &r, &d);
double tanx = double(b)/(a+r);
double ans = 0;
if(tan(d*pi/180) > tanx || (tanx > 0 && tan(d*pi/180) < 0)){
ans = sqrt((a+r)*(a+r)+b*b)-r;
}
else {
ans = (a+r)*cos(d*pi/180)+b*sin(d*pi/180)-r;
}
printf("%.12lf\n", ans);
}
return 0;
}
本文详细解析了CodeForces GYM102028D题目的解决方案,该题目源自2018-2019 ACM-ICPC亚洲区域赛焦作站比赛。通过使用C++实现的代码,文章展示了如何计算特定几何问题的解,涉及三角函数和条件判断,为参赛者和算法学习者提供了实用的参考。
834

被折叠的 条评论
为什么被折叠?



