Description

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

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.
 
 

Output

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.        

 
 

Sample Input

-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

Sample Output

SCORE: 240 to 240, TIE.
SCORE: 200 to 140, PLAYER 1 WINS. 这道题十分简单,但我的代码提交上去总是submit failed,可能是网不太好的原因,总是提交错误!!!我很生气!!!!!

但是我提交别人的代码就可以提交成功,应该是代码本身的缺陷吧,以下是我的代码
#include <iostream>
using namespace std;
int f(double x,double y)
{
double j=x*x+y*y;
if(j<=)return ;
else if(j<=)return ;
else if(j<=)return ;
else if(j<=)return ;
else if(j<=)return ;
else return ;
}
int main()
{
int i,x,y;
while(){
double a[];
for(i=;i<;i++)cin>>a[i];
if(a[]==-)break;
x=;
y=;
for(i=;i<;i+=)x+=f(a[i],a[i+]);
for(i=;i<;i+=)y+=f(a[i],a[i+]);
cout<<"SCORE: "<<x<<" to "<<y<<", ";
if(x==y)cout<<"TIE."<<endl;
if(x>y)cout<<"PLAYER 1 WINS."<<endl;
if(x<y)cout<<"PLAYER 2 WINS."<<endl;
}
//system("pause");
return ;
}

下面是提交成功的别人的代码

#include <iostream>
using namespace std;
int f(double x,double y)
{
double j=x*x+y*y;
if(j<=)return ;
else if(j<=)return ;
else if(j<=)return ;
else if(j<=)return ;
else if(j<=)return ;
else return ;
}
int main()
{
int x,y;
double a,b;
while(cin>>a){
if(a==-)break;
x=;
y=;
cin>>b;
x+=f(a,b);
for(int i=;i<;i++){
cin>>a>>b;
x+=f(a,b);
}
for(int i=;i<;i++){
cin>>a>>b;
y+=f(a,b);
}
cout<<"SCORE: "<<x<<" to "<<y<<", ";
if(x==y)cout<<"TIE."<<endl;
if(x>y)cout<<"PLAYER 1 WINS."<<endl;
if(x<y)cout<<"PLAYER 2 WINS."<<endl;
}
//system("pause");
return ;
}

也许是思路的大不同,我的代码没有真正的按照计算机的思路来,所以hdu无法接受我的代码,愁死了!!!!

G - Bullseye的更多相关文章

  1. H - Ones

    Description Given any integer 0 <= n <= 10000 not divisible by 2 or 5, some multiple of n is a ...

  2. Storyboards Tutorial 03

    这一节主要介绍segues,static table view cells 和 Add Player screen 以及 a game picker screen. Introducing Segue ...

  3. 文件图标SVG

    ​<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink ...

  4. Debian 11 “bullseye” 安装笔记

    作者:gc(at)sysin.org,主页:www.sysin.org Debian 版本:11 代号:bullseye 发布日期:2021.08.14 内核版本:5.10 $ uname -a Li ...

  5. 无法更新apt镜像源?树莓派安装最新版Debian11(bullseye)arm64位系统步骤

    镜像下载.域名解析.时间同步请点击阿里云开源镜像站 树莓派系统在2022年1月28日迎来了更新,更新了64位的系统,同时也有lite系统供我们使用.32位系统很多软件都用不了,特别是宝塔面板.下面是安 ...

  6. [转]Linux下g++编译与使用静态库(.a)和动态库(.os) (+修正与解释)

    在windows环境下,我们通常在IDE如VS的工程中开发C++项目,对于生成和使用静态库(*.lib)与动态库(*.dll)可能都已经比较熟悉,但是,在linux环境下,则是另一套模式,对应的静态库 ...

  7. CentOS 6.6 升级GCC G++ (当前最新版本为v6.1.0) (完整)

    ---恢复内容开始--- CentOS 6.6 升级GCC G++ (当前最新GCC/G++版本为v6.1.0) 没有便捷方式, yum update....   yum install 或者 添加y ...

  8. Linux deepin 下sublimes配置g++ openGL

    参考 :http://blog.csdn.net/u010129448/article/details/47754623 ubuntu 下gnome只要将代码中deepin-terminal改为gno ...

  9. [翻译svg教程]svg 中的g元素

    svg 中的<g>元素用来组织svg元素.如果一组svg元素被g元素包裹了,你可以通过对g元素进行变换(transform),被g元素包裹的元素也将被变换,就好这些被svg包裹的元素是一个 ...

随机推荐

  1. 改变navigationbar的底部线条颜色

    [[UINavigationBar appearance] setBackgroundImage:[UIImage new]forBarMetrics:UIBarMetricsDefault]; CG ...

  2. 7、Khala设备资源的申请和释放

    在实际业务中,我们每次登录后,可能需要在服务端维护一些设备相关的资源信息,而不同设备所需维护的资源信息又不尽相同.Khala提供了设备资源的维护储存功能,在此我们通过一个具体的业务中对其进行展示. 一 ...

  3. iOS UIWebView 访问https 绕过证书验证的方法

    在文件开始实现  allowsAnyHTTPSCertificateForHost 方法 @implementation NSURLRequest (NSURLRequestWithIgnoreSSL ...

  4. 解决mac ssh连linux中文乱码的问题[转]

    将Mac下/etc/ssh_config中的SendEnv LANG LC_*这一行用#号注释掉 reference: http://www.zhihu.com/question/20117388

  5. 远程访问TeamTalk的Mysql数据库被拒解决方法

    1.A Database Error Occurred 问题如图: 蓝狐给的解答是: 这是访问mysql出错了.解决办法参考:http://www.bkjia.com/jingyan/512248.h ...

  6. mysql----innodb统计信息

    对innodb 统计信息的控制可以通过如下几个常用的variables 来实现 1.innodb_stats_persistent: 这个参数控制着innodb的统计信息是否持久化到磁盘,先说明一下持 ...

  7. freebsd安装和图形界面安装

    通过上述的安装以后只有命令行界面,没有图形界面,如果想使用X Window就需要安装X 11和GNOME(或KDE). 1. 安装X 11(用root账户) 在确保虚拟机的CD-ROM加载了FreeB ...

  8. Mysql基本类型(五种年日期时间类型)——mysql之二

    转自:<MySQL技术内幕:时间和日期数据类型> http://tech.it168.com/a2012/0904/1393/000001393605_all.shtml

  9. 【Xamarin挖墙脚系列:打造独特的Xamarin.IOS开发环境】

    苹果的产品,依赖特定的开发环境. Mac  +  Xcode  不可缺少.所以,必须有Mac系统. 1-虚拟机搭建 2-土豪有Mac电脑设备 但是我觉得还是顺带上Visual Studio才是完美.. ...

  10. 仿新浪微博短网址PHP实现方案

    微博限制140字,但是我们知道有时需要分享一个类似淘宝商品的链接,很长,为了避免这个问题,所有了短网址的概念,废话不多说,直接把我的实现方案分享一下: 1)将长网址md5生成32位签名串,分为4段, ...