zoukankan      html  css  js  c++  java
  • 【Codeforces Round #465 (Div. 2) C】Fifa and Fafa

    【链接】 我是链接,点我呀:)
    【题意】

    在这里输入题意

    【题解】

    这个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;
    }
    
  • 相关阅读:
    HTML4如何让一个DIV居中对齐?float输入日志标题
    HTML3层叠样式表
    面向对象 学生考试计分题目
    C#总复习
    HTML2列表表单框架
    HTML1网页三部份内容
    HTML 5 JavaScript初步 编译运行.doc
    初识MYSQL
    数据库设计
    序列化和反序列化
  • 原文地址:https://www.cnblogs.com/AWCXV/p/8481022.html
Copyright © 2011-2022 走看看