WOJ1114-Bullseye

来源:互联网 发布:midas civil软件下载 编辑:程序博客网 时间:2024/05/21 06:29

A simple dartboard consists of a flat, circular piece of cork with concentric rings drawn on it. Darts are thrown at the board by players in
an attempt to hit the center of the dartboard (the Bullseye). The region between each pair of rings (or the center and the first ring)
represents a certain point value. The closer the region is to the center of the dartboard, the more points the region is worth, as shown in
the diagram below:



Ring radii are at 3", 6", 9", 12" and 15" (the Bullseye has a diameter of 6"). A game of Simple Darts between two players is played as
follows. The first player throws 3 darts at the board. A score is computed by adding up the point values of each region that a dart lands in.
The darts are removed. The second player throws 3 darts at the board; the score for player two is computed the same way as it is for player
one. The player with the higher score wins.

For this problem, you are to write a program that computes the scores for two players, and determine who, if anyone, wins the game. If a dart
lands exactly on a ring (region boundary), the higher point value is awarded. Any dart outside the outer ring receives no points. For the
purposes of this problem, you can assume that a dart has an infinitely fine point and can not land paritially on a ring; it is either on the
ring or it is not on the ring. Standard double precision floating point operations will be should be used.

输入格式

Input consists of 1 or more datasets. A dataset is a line with 12 double-precision values separated by spaces. Each pair of values represents the X
and Y distances respectively of a dart from the center of the board in inches. (the center is located at X = 0, Y = 0. The range of values are: -
20.0<=X, Y<=20.0. Player one's darts are represented by the first 3 pairs of values, and player two's by the last 3 pairs of values. Input is
terminated by the first value of a dataset being -100.

输出格式

For each dataset, print a line of the form:
SCORE: N to M, PLAYER P WINS.
Or:
SCORE: N to M, TIE.
N is player one's score, and M is player two's score. P is either 1 or 2 depending on which player wins. All values are non-negative integers.
Formula

Recall: r^2 = x^2 + y^2 where r is the radius, and (x, y) are the coordinates of a point on the circle.

样例输入

-9 0 0 -4.5 -2 2 9 0 0 4.5 2 -2-19.0 19.0 0 0 0 0 3 3 6 6 12 12-100 0 0 0 0 0 0 0 0 0 0 0

样例输出

SCORE: 240 to 240, TIE.SCORE: 200 to 140, PLAYER 1 WINS.

根据点到圆心的距离,把分算出来比较下就可以了

#include<stdio.h>#include<math.h>int fen(double x,double y){double r=x*x+y*y;if(r<=3*3)return 100;else if(r<=6*6)return 80;else if(r<=9*9)return 60;else if(r<=12*12)return 40;else if(r<=15*15)return 20;elsereturn 0;}int main(){int score1,score2;double a1,a2,a3,a4,a5,a6,b1,b2,b3,b4,b5,b6;while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf",&a1,&a2,&a3,&a4,&a5,&a6,&b1,&b2,&b3,&b4,&b5,&b6)){if(a1==-100)break;score1=fen(a1,a2)+fen(a3,a4)+fen(a5,a6);score2=fen(b1,b2)+fen(b3,b4)+fen(b5,b6);if(score1==score2)printf("SCORE: %d to %d, TIE.\n",score1,score2);else if(score1>score2)printf("SCORE: %d to %d, PLAYER 1 WINS.\n",score1,score2);elseprintf("SCORE: %d to %d, PLAYER 2 WINS.\n",score1,score2);}return 0;} 


原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 租的车处理违章怎么办 以租代购车不要怎么办 订车的合同掉了怎么办 买车合同丢了怎么办 车的证件都丢了怎么办 桃树直立的徒长枝怎么办 月季花长了独枝怎么办? 6岁半B超没子宫怎么办 学生学籍号和身份证号不一致怎么办 学生学籍号和身份证号不一样怎么办 领导交代的任务完不成怎么办 洗衣机里的衣服有味道怎么办 新买的洗衣机有味道怎么办 模拟工业装置没有数据验证怎么办 民办学校的指标生学费怎么办 孩子上初中后成绩不好怎么办 孩子考最后一名怎么办 数学大题不会做怎么办 小学六年级数学考30分怎么办 六年级数学考了30分怎么办 数学考了30分怎么办 没有给直接领导报到怎么办 小学二年级成绩不好怎么办 初中孩子上课注意力不集中怎么办 学生打架家长争吵老师怎么办 我和我老婆感情危机怎么办 数学作业做得慢怎么办 待转弯区变红灯怎么办 大班健康发生火灾怎么办教案 数字化审图图纸提交不了怎么办 监狱建筑师没电了怎么办 ios短信提示不弹出怎么办 ie游览器图标删了怎么办 电脑上ie卸载了怎么办 打开cad浏览器闪退怎么办 dnf进游戏闪退怎么办 苹果8出现闪退怎么办 手机浏览器老是自动打开软件怎么办 打开手机浏览器为什么是英文怎么办 ie浏览器删除掉了怎么办 手机360浏览器卸载不掉怎么办