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. oracle导出数据显示出现ora-00109或者LRM-00109出错修改办法

    出现这种问题是因为日期格式的问题,调整日期格式后就可以了 改成yyyy-mm-dd的格式就好了

  2. OC对象:封装、继承、多态的使用举例一

    // 该代码在网上找的视频中的例子,感觉很适合类和对象分不清楚的同学参考,仅供学习分享,谢谢 // 创建一个Pointtest类,用属性x.y表示点的坐标位置,求两点之间的距离,使用两种方法:类方法和 ...

  3. IOS 手机端搜索硬件设备 --- 物联网

    #include<stdio.h> #include<stdlib.h> #include<string.h> #include<errno.h> #i ...

  4. QT5.5实现串口通信

    QT5.1以上版本自带QtSerialPort集成库,只要在头文件中集成 #include <QtSerialPort/QSerialPort> #include <QtSerial ...

  5. [hdu5113]Black And White2014北京赛区现场赛B题(搜索加剪枝)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Black And White Time Limit: 2000/2000 MS ...

  6. SeekBar和RatingBar

    今天在看一个音乐播放器的源代码时候用到了SeekBar,就翻出来mars老师的视频复习了一下,然后综合使用了一下. 首先先看下运行效果:   下来我们看看布局文件的设计: main.xml: < ...

  7. 【Python网络编程】多线程聊天软件程序

    课程设计的时候制作的多线程聊天软件程序 基于python3.4.3 import socket import pickle import threading import tkinter import ...

  8. Stripies(POJ 1862 贪心)

    Stripies Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 14151   Accepted: 6628 Descrip ...

  9. PHP标记

    1. xml风格 <?php echo 'ok'; ?> 推荐风格 2. 简短风格 <? echo 'ok'; ?> 限制条件:在配置文件中启用short_open_tag选项 ...

  10. T-SQL 运算符

    运算符 1.算术运算符 算术运算符 说明 + 加法 - 减法 * 乘法 / 除法 % 取模,两个整数相除后的余数 2.位运算符 位运算符 说明 &(与.and) 按位逻辑与运算 |(或.OR) ...