UVALive 6262 Darts

Description

Download as PDF

Consider a game in which darts are thrown at a board. The board is formed by 10 circles with radii 20, 40, 60, 80, 100, 120, 140, 160, 180, and 200 (measured in millimeters), centered at the origin. Each throw is evaluated depending on where the dart hits the board. The score is p points (p $ \in$ {1, 2,..., 10}) if the smallest circle enclosing or passing through the hit point is the one with radius 20 . (11 - p). No points are awarded for a throw that misses the largest circle. Your task is to compute the total score of a series of n throws.

Input

The first line of the input contains the number of test cases T. The descriptions of the test cases follow:

Each test case starts with a line containing the number of throws n (1$ \le$n$ \le$106). Each of the next n lines contains two integers x and y (- 200$ \le$x, y$ \le$200) separated by a space -- the coordinates of the point hit by a throw.

Output

Print the answers to the test cases in the order in which they appear in the input. For each test case print a single line containing one integer -- the sum of the scores of all n throws.

Sample Input

 

1
5
32 -39
71 89
-60 80
0 0
196 89

Sample Output

 

29
 1 #include<iostream>  
 2 #include<string.h>  
 3 #include<stdio.h>  
 4 #include<ctype.h>  
 5 #include<algorithm>  
 6 #include<stack>  
 7 #include<queue>  
 8 #include<set>  
 9 #include<math.h>  
10 #include<vector>  
11 #include<map>  
12 #include<deque>  
13 #include<list>  
14 using namespace std;
15 int d(int a,int b)
16 {
17     if(200*200<(pow(a,2)+pow(b,2)))
18     return 0;
19         if(180*180<(pow(a,2)+pow(b,2))&&(pow(a,2)+pow(b,2)))
20         return 1;
21         if(160*160<(pow(a,2)+pow(b,2))&&(pow(a,2)+pow(b,2)))
22         return 2;
23         if(140*140<(pow(a,2)+pow(b,2))&&(pow(a,2)+pow(b,2)))
24         return 3;
25         if(120*120<(pow(a,2)+pow(b,2))&&(pow(a,2)+pow(b,2)))
26         return 4;
27         if(100*100<(pow(a,2)+pow(b,2))&&(pow(a,2)+pow(b,2)))
28         return 5;
29         if(80*80<(pow(a,2)+pow(b,2))&&(pow(a,2)+pow(b,2)))
30         return 6;
31         if(60*60<(pow(a,2)+pow(b,2))&&(pow(a,2)+pow(b,2)))
32         return 7;
33         if(40*40<(pow(a,2)+pow(b,2))&&(pow(a,2)+pow(b,2)))
34         return 8;
35         if(20*20<(pow(a,2)+pow(b,2))&&(pow(a,2)+pow(b,2)))
36         return 9;
37         return 10;
38 }
39 int main()
40 {
41     int n;
42     cin>>n;
43     while(n--)
44     {
45         int m,ans=0;
46         cin>>m;
47         while(m--)
48         {
49         int a,b;
50         scanf("%d%d",&a,&b);
51         ans+=d(a,b);
52         }    
53         printf("%d\n",ans);
54     }
55     return 0;
56 }
View Code

 

转载于:https://www.cnblogs.com/qscqesze/p/3877212.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值