• Codeforces Round #430 (Div. 2)


    题目链接:http://codeforces.com/contest/842/problem/B

    题意:给定一个圆心在原点(0,0)半径为r的大圆和一个圆内的圆环长度d,然后给你n个小圆,问你有多少个小圆完全位于圆环中

    思路:求出每个小圆的圆心和原点的距离dist。 如果满足dist[i]-r[i]>=(r-d)&&dist[i]+r[i]<=r,说明这个小圆完全位于圆环。

    #define _CRT_SECURE_NO_DEPRECATE
    #include<iostream>
    #include<cstring>
    #include<string>
    #include<algorithm>
    #include<stdio.h>
    #include<queue>
    #include<vector>
    #include<stack>
    #include<map>
    #include<set>
    #include<time.h>
    #include<cmath>
    #include<sstream>
    #include<assert.h>
    using namespace std;
    typedef long long int LL;
    const int inf = 0x3f3f3f3f;
    const LL INF = 0x3f3f3f3f3f3f3f3fLL;
    const int MAXN = 1e5 + 24;
    int main(){
    //#ifdef kirito
    //    freopen("in.txt", "r", stdin);
    //    freopen("out.txt", "w", stdout);
    //#endif
    //    int start = clock();
        int R,d,n,x,y,r;
        while (~scanf("%d%d",&R,&d)){
            scanf("%d", &n); int ans = 0;
            for (int i = 1; i <= n; i++){
                scanf("%d%d%d", &x, &y, &r);
                double dist = sqrt(1.0*x*x + 1.0*y*y);
                if ((dist-r) >= (R - d) && (dist+r) <= R){
                    ans++;
                }
            }
            printf("%d
    ", ans);
        }
    //#ifdef LOCAL_TIME
    //    cout << "[Finished in " << clock() - start << " ms]" << endl;
    //#endif
        return 0;
  • 相关阅读:
    【数据结构】堆栈
    【数据结构】线性表
    【算法】最大子列和问题
    【算法】复杂度的渐近表示
    【算法】什么是好的算法
    【算法】什么是算法
    【数据结构】什么是数据结构
    MySQL数据备份脚本
    二进制安装MySQL-5.7.28
    搭建zabbix+grafana监控
  • 原文地址:https://www.cnblogs.com/kirito520/p/7452347.html
Copyright © 2020-2023  润新知