G - Bullseye
Description
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
Output
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的更多相关文章
- H - Ones
Description Given any integer 0 <= n <= 10000 not divisible by 2 or 5, some multiple of n is a ...
- Storyboards Tutorial 03
这一节主要介绍segues,static table view cells 和 Add Player screen 以及 a game picker screen. Introducing Segue ...
- 文件图标SVG
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink ...
- Debian 11 “bullseye” 安装笔记
作者:gc(at)sysin.org,主页:www.sysin.org Debian 版本:11 代号:bullseye 发布日期:2021.08.14 内核版本:5.10 $ uname -a Li ...
- 无法更新apt镜像源?树莓派安装最新版Debian11(bullseye)arm64位系统步骤
镜像下载.域名解析.时间同步请点击阿里云开源镜像站 树莓派系统在2022年1月28日迎来了更新,更新了64位的系统,同时也有lite系统供我们使用.32位系统很多软件都用不了,特别是宝塔面板.下面是安 ...
- [转]Linux下g++编译与使用静态库(.a)和动态库(.os) (+修正与解释)
在windows环境下,我们通常在IDE如VS的工程中开发C++项目,对于生成和使用静态库(*.lib)与动态库(*.dll)可能都已经比较熟悉,但是,在linux环境下,则是另一套模式,对应的静态库 ...
- CentOS 6.6 升级GCC G++ (当前最新版本为v6.1.0) (完整)
---恢复内容开始--- CentOS 6.6 升级GCC G++ (当前最新GCC/G++版本为v6.1.0) 没有便捷方式, yum update.... yum install 或者 添加y ...
- Linux deepin 下sublimes配置g++ openGL
参考 :http://blog.csdn.net/u010129448/article/details/47754623 ubuntu 下gnome只要将代码中deepin-terminal改为gno ...
- [翻译svg教程]svg 中的g元素
svg 中的<g>元素用来组织svg元素.如果一组svg元素被g元素包裹了,你可以通过对g元素进行变换(transform),被g元素包裹的元素也将被变换,就好这些被svg包裹的元素是一个 ...
随机推荐
- Sql server 数据库 单用户切换为多用户
使用master 下的sysprocesses 查询 db正在使用的spid 如 select spid from sysprocesseswhere dbid=DB_ID('DbName') 然后执 ...
- tomcat解决乱码
今天遇到个问题,太尴尬了: 本来做好并测试号的项目提交到svn, 组员下了之后,又部分url传递的中文参数在另一个jsp接收出现乱码(只有我的不乱码). 改了之后更尴尬的事情发生了:组员的全部不乱码, ...
- Windows,Linux换行知识
换行符在写文件的时候用得上 Linux: "\n"Windows: "\r\n" 注意:换行符一定要加上双引号,单引号是没有用的.
- asp.net js 获取服务器控件值
最近在弄js 但是设计到获取服务器控件的值,有点模糊.百度查了资料都达不到效果.现在看看这个,希望朋友们能用上!! <asp:Label ID="lbDepartName" ...
- css派生选择器
后代选择器:即包含选择器,选择某元素的后代元素. 子元素选择器:只能选择某元素的子元素. 相邻兄弟选择器:可选择紧接在另一个元素后的元素,且两者有相同的夫元素.
- vs2010中自动实现抽象方法
由于刚接触vs,感官上虽然和eclipse差不多,但是一些快捷都不太相同,导致一开始使用时候非常不习惯. 不过刚开始嘛,写点相当小白的东西,也没有用到太多功能,也就暂时忽视,用的时候再说. 但是今天, ...
- 使用DBUtils小框架
DBUtils对sqlserver好像支持不怎么好,经常出现问题 比如 三月 14, 2015 10:19:32 上午 com.mchange.v2.log.MLog 信息: MLog clients ...
- angularJS常用命令
首先使用命令行进入你要编辑的web项目目录下: (一)编译浏览项目 1:grunt build 对web项目编译: 2:grunt server 装载(在浏览器上查看页面): 3:ctrl ...
- 从客户端(******)中检测到有潜在危险的 Request.Form 值。
在 提交表单时候,asp.net 提示:"从客户端(......)中检测到有潜在危险的 Request.Form 值" .asp.net中的请求验证特性提供了某一等级的保护措施防止 ...
- 线程初步了解 - <第一篇>
操作系统通过线程对程序的执行进行管理,当操作系统运行一个程序的时候,首先,操作系统将为这个准备运行的程序分配一个进程,以管理这个程序所需要的各种资源.在这些资源之中,会包含一个称为主线程的线程数据结构 ...