zoukankan      html  css  js  c++  java
  • 【Good Bye 2017 C】 New Year and Curling

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

    在这里输入题意

    【题解】

    枚举前i-1个圆。 哪些圆和它相交。 取圆心纵坐标最大的那个圆就可以了。

    【代码】

    #include <bits/stdc++.h>
    using namespace std;
    
    const int N = 1e3;
    
    vector<pair<int,double> >now;
    int a[N+10],n,r;
    
    int main(){
    	#ifdef LOCAL_DEFINE
    	    freopen("rush_in.txt", "r", stdin);
    	#endif
    	ios::sync_with_stdio(0),cin.tie(0);
        cin >>n >> r;
        for (int i = 1;i <= n;i++) cin >> a[i];
        for (int i = 1;i <= n;i++){
            int len = now.size();
            pair<int,double> kk;
            kk.second = -1;
            for (int j = 0;j < len;j++)
                if (now[j].first>=a[i]-2*r && now[j].first<=a[i]+2*r){
                    double deltax = abs(a[i]-now[j].first);
                    double r2 = 2*r;
                    double deltay = sqrt(r2*r2-deltax*deltax);
                    kk.second = max(kk.second,now[j].second+deltay);
                }
            if (kk.second<0)
                now.push_back(make_pair(a[i],r));
            else{
                now.push_back(make_pair(a[i],kk.second));
            }
        }
        for (int i = 0;i < (int)now.size();i++){
            cout <<fixed<<setprecision(10)<<now[i].second<<' ';
        }
    	return 0;
    }
    
  • 相关阅读:
    小程序支付
    小程序传参
    git
    学习过程遇到问题的解决方法
    进程创建注意事项:函数及对应包
    进程创建:函数及对应包
    mac解决eclipse 端口占用问题
    暴力
    doc2vec
    Java正则表达式的解释说明
  • 原文地址:https://www.cnblogs.com/AWCXV/p/8149047.html
Copyright © 2011-2022 走看看