zoukankan      html  css  js  c++  java
  • 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
    "
    天晴了,起飞吧
  • 相关阅读:
    大聊Python----SocketServer
    2、MySQL常见数据库引擎及比较?
    大聊Python----通过Socket实现简单的ssh客户端
    1、列举常见的关系型数据库和非关系型都有那些?
    uva12563 Jin Ge Jin Qu hao(01背包)
    UVA 12174 Shuffle(滑动窗口)
    C++中substr函数的用法
    uva11078
    11462 Age Sort(计数排序)
    UVA 11988 Broken Keyboard (a.k.a. Beiju Text) (链表,模拟)
  • 原文地址:https://www.cnblogs.com/jianqiao123/p/11333089.html
Copyright © 2011-2022 走看看