备战省赛--Chaarshanbegaan at Cafebazaar

版权声明:转载请附上原文链接哟! https://blog.csdn.net/weixin_44170305/article/details/89742641

如花美眷,似水流年,回得了过去,回不了当初。

题目描述

Chaarshanbegaan is a gathering event at Cafebazaar similar to TGIF events at Google. Some entertainment programs like pantomime, foosball, Xbox/PS4, and several board games are part of the event. You are going to set up a dart game in Chaarshanbegaan. As a techie organizing a game for techies, you would rather use a smart screen and write a program to calculate the scores instead of hanging a traditional dartboard and scoring the shots manually. Your program must get the coordinates of dart shots for a player and calculate his/her total score. The score for each dart shot (at point (x, y)) is  calculated based on its distance from the center of the dartboard (point (0, 0)). If the distance is d millimeters, the score is calculated based on the following table:

输入

The first line of the input contains a single integer N as the number of dart shots for a player (1 ⩽ N ⩽ 100). Each of the next N lines contains two space-separated integers as the coordinates (x, y) of a dart shot. The coordinates are in millimeters and their absolute values will not be greater than 300.

输出

Print a single line containing the total score of the player.

样例输入

复制样例数据

2
4 7
-31 -5

样例输出

18
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
int a[1000010];
int main()
{
    int n;
    int sum=0;
    scanf("%d",&n);
    while(n--)
    {
        int x,y;
        int i,j;
        scanf("%d%d",&x,&y);
        int t=x*x+y*y;
        if(t<=100)
            sum+=10;
        else if(t>100&&t<=900)
        {
            sum+=9;
        }
        else if(t>900&&t<=2500)
        {
            sum+=8;
        }
        else if(t>2500&&t<=4900)
        {
            sum+=7;
        }
        else if(t>4900&&t<=8100)
        {
            sum+=6;
        }
        else if(t>8100&&t<=12100)
        {
            sum+=5;
        }
        else if(t>12100&&t<=16900)
        {
            sum+=4;
        }
        else if(t>16900&&t<=22500)
        {
            sum+=3;
        }
        else if(t>22500&&t<=28900)
        {
            sum+=2;
        }
        else if(t>28900&&t<=36100)
        {
            sum+=1;
        }
        else
            sum+=0;
 
    }
    printf("%d\n",sum);
    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_44170305/article/details/89742641