【Codeforces Round #465 (Div. 2) C】Fifa and Fafa
and Codeforces div round
2023-09-14 09:03:44 时间
【链接】 我是链接,点我呀:)
【题意】
【题解】
这个x2,y2和圆心(x1,y1)相连。形成的直线和圆交于点(x3,y3) 则(x2,y2)和(x3,y3)的中点就是所求圆的圆心。 半径就是x2,y2到x3,y3的距离的一半。 写个向量的方法,求出x3,y3的坐标就好了。【代码】
#include <bits/stdc++.h>
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define ls l,mid,rt<<1
#define rs mid+1,r,rt<<1
#define double long double
using namespace std;
const double pi = acos(-1);
const int dx[4] = {0,0,1,-1};
const int dy[4] = {1,-1,0,0};
LL R,x1,y1,x2,y2;
LL sqr(LL x){
return x*x;
}
void solve(){
cin >> R >> x1 >> y1 >> x2 >> y2;
if (sqr(x1-x2)+sqr(y2-y1)>=sqr(R)){
cout<<x1<<' '<<y1<<' '<<R<<endl;
return;
}
if (x1==x2 && y1==y2){
cout<<fixed<<setprecision(10)<<x1+R/2.0<<' '<<y1<<' ';cout<<fixed<<setprecision(10)<<(double)R/2.0<<endl;
return;
}
double t1 = sqrt(sqr(x1-x2)+sqr(y2-y1)),t2 = R;
double x3 = x1-t2/t1*(x2-x1);
double y3 = y1-t2/t1*(y2-y1);
cout<<fixed<<setprecision(10)<<(x2+x3)/2.0<<' '<<(y2+y3)/2.0<<' '<<(t1+t2)/2.0<<endl;
}
int main(){
#ifdef LOCAL_DEFINE
freopen("rush_in.txt", "r", stdin);
#endif
ios::sync_with_stdio(0),cin.tie(0);
int T;
T = 1;
while(T--){
solve();
}
return 0;
}
相关文章
- A review on TinyML: State-of-the-art and prospects PartI
- Android studio更新后出现警告:Warning:The `android.dexOptions.incremental` property is deprecated and it has
- CodeForces 750A New Year and Hurry
- ORA-13633: The task string was interrupted and needs to be resumed. ORACLE 报错 故障修复 远程处理
- :Beautiful Linux: The Look and Feel of Freedom(好看的linux)
- MySQL中的OR与AND操作符比较(mysqlor和and)
- Redis and Go: A Perfect Combination(redisgo)
- MySQL:Exploring Its Existence and Benefits(mysqlexists)
- Exploring the Beautiful Alliance of Linux and Monaco: A Powerful Match for Tech Innovators(linuxmonaco)
- Mastering PWD Command in Linux: Essential Tips and Tricks(pwdlinux)
- Exploring the Benefits and Challenges of Implementing a MySQL Multidatabase Architecture with Multiple Data Centers.(mysql多数据中心)
- Exploring the Power of Git and Redis: Enhance Your Development Process(gitredis)
- Mastering MongoDB: Essential Tips and Tricks for Efficient Database Operations(mongodb数据库操作)
- MySQL中的AND逻辑操作符是什么(mysql中and是什么)
- MySQL中如何正确使用AND运算符(mysql中and怎么用)
- MySQL中的AND和OR使用逻辑运算符优化查询语句(mysql中and与or)
- Oracle中使用除了And的其他查询关键字(oracle中除了and)
- Oracle中使用AND运算符的示例分析(oracle中and用法)
- Oracle 数据库中使用AND拼接的威力(oracle中and拼接)