Gym - 102318E Simple Darts 投飞镖 判断位置 模拟题

题意:一个飞镖圆盘 不同位置有不同分数 告诉你坐标 问你最后多少分
思路:模拟即可 注意求度数方式 这里用atan(x)*180.0/3.1415926
这里的x是斜率
最后判断出与x轴成的角度即可
下面是ac代码:

#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#define ll long long
#define inf 0x3f3f3f3f
#define sd(a) scanf("%d",&a)
#define sdd(a,b) scanf("%d%d",&a,&b)
#define cl(a,b) memset(a,b,sizeof(a))
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define sddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define dbg() printf("aaa\n")
using namespace std;
int main() {
	int T;
    sd(T);
    while(T--){
        int w,r1,r2,r3;
        sd(w);sddd(r1,r2,r3);
        int n;sd(n);
        int ans=0;
        while(n--){
            double x,y;
            scanf("%lf%lf",&x,&y);
            double d=x*x+y*y;
            if(d<(double)r1*(double)r1){
                ans+=50;
            }else if(d>(double)r3*(double)r3){
                ans+=0;
            }else {
                //求夹角
                int pos;//象限
                if(x>0&&y>0) pos=1;
                else if(x<0&&y>0) pos=2;
                else if(x<0&&y<0) pos=3;
                else pos=4;
                double t=atan(y/x)*180.0/3.1415926;//角度
                if(pos==2||pos==3) t+=180.0;
                else if(pos==4) t+=360.0;
                double ba=360.0/(double)w;//每份多少度
                int k=(int)(t/ba)+1;//在第几部分
                if(d>(double)r1*(double)r1&&d<(double)r2*(double)r2){
                    ans+=k*2;
                }else if(d>(double)r2*(double)r2&&d<(double)r3*(double)r3){
                    ans+=k;
                }
            }
        }
        printf("%d\n",ans);
    }
	return 0;
}

A staple to many game rooms, darts is a fun game that doesn’t require a lot of physical space. The standard dartboard (see Figure 1) consists of 6 concentric rings and 20 wedges, dividing the board into a number of regions, each with well-defined scores (note: for a higher picture resolution/clarity, fewer than 20 wedges are depicted in Figure1). The centermost ring is scored as a double bullseye, while the second ring gives the score of a single bullseye. Beyond the second ring, each wedge has a score between 1 and 20 with the spaces between certain rings having double and triple score modifiers. A new, simpler version of the game is being proposed to attract younger players to the game.

企业微信截图_15859737655304.png企业微信截图_15859738034200.png

The Problem:

The simpler version of the game is illustrated in Figure 2. More specifically, the board consists of exactly 3 (instead of 6) concentric rings and it may have fewer (instead of exactly 20) wedges. Also, in the simpler board, the wedges are of equal size. The scoring for this simple version is as follows:

Assume the board is centered at the origin (“0,0” in Cartesian plane). Let w refer to the number of wedges on the board (8 in Figure 2), and let b, d, s refer to (respectively) the radii of the smallest, second smallest, and the largest rings.

The wedge immediately above the positive x axis (Wedge 1 in Figure 2) is scored at 1 point and the score for each wedge is increased by 1 in a counterclockwise fashion, thus resulting in the wedge below the positive x axis (Wedge 8 in Figure 2) having a score of w. The area within the circle centered at the origin with radius b represents the bullseye and is always scored at 50 points. The area between radii b and d denotes the double ring and any dart landing within the double ring is scored at twice the value of the surrounding wedge. The area between radii d and s denotes the single ring and any dart landing within the single ring is scored at the value of the surrounding wedge. Any dart landing outside the dartboard carries a score of zero (0).

Given the description (layout) of such a board centered at the origin and a number of dart throws, you are to calculate the total score.

The Input:

The first input line contains a positive integer, n, indicating the number of test cases to process. Each test case will contain multiple input lines. The first line of each test case will contain four integers separated by a space: w (2 ≤ w ≤ 20), representing the number of equal-sized wedges on the board, followed by b, d, s (0 < b < d < s < 100), representing the radii of the bullseye, double ring and single ring regions of the board. The second input line of each test case will contain an integer, t (1 ≤ t ≤ 100), indicating the number of dart throws. Each of the following t input lines contains two floating point numbers (three decimal places), x and y (-100 ≤ x,y ≤ 100), providing the Cartesian coordinates of a dart throw. Assume that no dart will land within 10^-5 of any boundary (line or arc/curve).

The Output:

For each test case, output a single integer on a line by itself indicating the total score for all dart throws.
样例输入

3
4 7 13 20
2
4.000 4.000
6.000 -4.000
10 1 6 10
1
20.000 -0.500
8 3 7 50
5
-0.750 1.207
1.180 3.132
27.111 -44.630
-43.912 -22.104
2.000 -6.000

样例输出

58
0
73

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值