zoukankan      html  css  js  c++  java
  • Codeforces Round #610 (Div. 2) A. Temporarily unavailable

    链接:

    https://codeforces.com/contest/1282/problem/A

    题意:

    Polycarp lives on the coordinate axis Ox and travels from the point x=a to x=b. It moves uniformly rectilinearly at a speed of one unit of distance per minute.

    On the axis Ox at the point x=c the base station of the mobile operator is placed. It is known that the radius of its coverage is r. Thus, if Polycarp is at a distance less than or equal to r from the point x=c, then he is in the network coverage area, otherwise — no. The base station can be located both on the route of Polycarp and outside it.

    Print the time in minutes during which Polycarp will not be in the coverage area of the network, with a rectilinear uniform movement from x=a to x=b. His speed — one unit of distance per minute.

    思路:

    6种情况

    代码:

    // #include<bits/stdc++.h>
    #include<iostream>
    #include<cstdio>
    #include<vector>
    #include<string.h>
    #include<set>
    #include<queue>
    #include<algorithm>
    #include<math.h>
    using namespace std;
    typedef long long LL;
    typedef unsigned long long ULL;
    const int MOD = 1e9+7;
    const int MAXN = 1e3+10;
    
    int main()
    {
        int a, b, c, r;
        int t;
        scanf("%d", &t);
        while(t--)
        {
            scanf("%d%d%d%d", &a, &b, &c, &r);
            if (a > b)
                swap(a, b);
            int lef = c-r, rig = c+r;
            if (a >= lef && b <= rig)
                puts("0");
            else if (a < lef && b > rig)
                printf("%d
    ", (lef-a)+(b-rig));
            else if (a < lef && b < lef)
                printf("%d
    ", b-a);
            else if (a > rig && b > rig)
                printf("%d
    ", b-a);
            else if (a < lef)
                printf("%d
    ", lef-a);
            else
                printf("%d
    ", b-rig);
        }
    
        return 0;
    }
    
  • 相关阅读:
    win10下安装基于caffe的 Faster-Rcnn
    Caffe学习系列
    Caffe 分类问题 Check failed: error == cudaSuccess (2 vs. 0) out of memory
    Windows 10下安装配置Caffe并支持GPU加速(修改版)
    Python 基础语法
    Halcon 彩色图片通道分割处理
    halcon 特征测量
    川崎机器人c#通讯(转)
    Halcon 2D测量
    Halcon 1D测量
  • 原文地址:https://www.cnblogs.com/YDDDD/p/12098798.html
Copyright © 2011-2022 走看看