• CodeForces Gym–101492F Hitting the target


    F. Hitting the target

    time limit per test

    1.0 s

    memory limit per test

    512 MB

    input

    standard input

    output

    standard output

    Sitting in front of the computer for too long is no good for your health. Keeping this in mind, the MaratonIME coaches decided to motivate the contestants to practice sports, not just programming. They didn't want to stick with the basics, so they chose the bow and arrow.

    However, they noticed that too many people showed up at practice sessions just to shoot arrows. To discourage people with no interest in programming, they decided to add a requirement for shooting arrows: one would have to code a program that takes the coordinates of 3 arrows and record the final score. The target is made of ten concentric circles of proportional radii, that is, the smallest circle has radius R, the second one has radius 2R, the third one has radius 3R, and so on. The circle with smallest radius grants 10 points, and the largest one awards only 1 point. An arrow that hits the boundary between two circles grants the largest of the two scores.

    Don't miss your opportunity to participate at the programming contest: write this program.

    Input

    The input has a line that has an integer R, the radius of the smallest circle. Next there are three lines with pairs of integers, x and y, the points in the target hit by each arrow. The target center is at coordinate (0, 0).

    • 1 ≤ R ≤ 102
    •  - 103 ≤ x, y ≤ 103

    Output

    The output has a single integer: the final score.

    Examples

    input

    Copy

    1
    0 0
    0 1
    0 0

    output

    Copy

    30

    input

    Copy

    2
    0 0
    0 2
    0 3

    output

    Copy

    29
    此题纯水题,但是我还是CE了很多次;
    就是把r=sqrt(double(x*x+y*y));写成了r=sqrt(x*x+y*y);
     
    AC代码:
    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <math.h>
    #include <cmath>
    #include <cstring>
    using namespace std;
    int main(){
        int R;
        int x,y;
        int point;
        int sum=0;
        double r;
        cin>>R;
        for(int i=1;i<=3;i++){
            cin>>x>>y;
            r=sqrt(double(x*x+y*y));
            if(r>=0&&r<=R) point=10;
            else if(r>R&&r<=2*R) point=9;
            else if(r>2*R&&r<=3*R) point=8;
            else if(r>3*R&&r<=4*R) point=7;
            else if(r>4*R&&r<=5*R) point=6;
            else if(r>5*R&&r<=6*R) point=5;
            else if(r>6*R&&r<=7*R) point=4;
            else if(r>7*R&&r<=8*R) point=3;
            else if(r>8*R&&r<=9*R) point=2;
            else if(r>9*R&&r<=10*R) point=1;
            else if(r>10*R) point=0;
            sum+=point;
        }
        printf("%d
    ",sum);
        return 0;
    }

    CE代码:

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <math.h>
    #include <cmath>
    #include <cstring>
    using namespace std;
    int main(){
        int R;
        int x,y;
        int point;
        int sum=0;
        double r;
        cin>>R;
        for(int i=1;i<=3;i++){
            cin>>x>>y;
            r=sqrt(x*x+y*y);
            if(r>=0&&r<=R) point=10;
            else if(r>R&&r<=2*R) point=9;
            else if(r>2*R&&r<=3*R) point=8;
            else if(r>3*R&&r<=4*R) point=7;
            else if(r>4*R&&r<=5*R) point=6;
            else if(r>5*R&&r<=6*R) point=5;
            else if(r>6*R&&r<=7*R) point=4;
            else if(r>7*R&&r<=8*R) point=3;
            else if(r>8*R&&r<=9*R) point=2;
            else if(r>9*R&&r<=10*R) point=1;
            else if(r>10*R) point=0;
            sum+=point;
        }
        printf("%d
    ",sum);
        return 0;
    }

    CE代码提交结果:

    "Canu0027t compile file:
    program.cpp
    program.cpp(17) : error C2668: u0027sqrtu0027 : ambiguous call to overloaded function
            c:Program Files (x86)Microsoft Visual Studio 10.0VCINCLUDEmath.h(589): could be u0027long double sqrt(long double)u0027
            c:Program Files (x86)Microsoft Visual Studio 10.0VCINCLUDEmath.h(541): or       u0027float sqrt(float)u0027
            c:Program Files (x86)Microsoft Visual Studio 10.0VCINCLUDEmath.h(127): or       u0027double sqrt(double)u0027
            while trying to match the argument list u0027(int)u0027
    "
    天晴了,起飞吧
  • 相关阅读:
    bzoj 2882: 工艺 后缀自动机
    bzoj 2002: 弹飞绵羊 Link-Cut-Tree
    bzoj 3881: [Coci2015]Divljak AC自动机
    bzoj 2553: [BeiJing2011]禁忌 AC自动机+矩阵乘法
    bzoj 3172: [Tjoi2013]单词 fail树
    bzoj 2434: 阿狸的打字机 fail树+离线树状数组
    bzoj 1030: 文本生成器 AC自动机+dp
    SAS FORMAT 逻辑库存储 【输出格式 没有找到或无法加载】解决方法
    PROC UNIVARIATE 简单示例
    SAS ODS GRAPHICS SGPLOT 画图 指存放定路径、名称、指定格式
  • 原文地址:https://www.cnblogs.com/jianqiao123/p/11333089.html
Copyright © 2020-2023  润新知