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包裹的元素是一个 ...
随机推荐
- Java Timer触发定时器
XML: <!-- Java Timer定时 --> <!-- <bean id="shortUrlTask" class=" com.sprin ...
- unity 打包 windows 运行 紫色 粉红色
unity下建立了个小demo,在editer里面运行正常.如下 但是一旦打包发布到android或者windows下就出现了类似这种情况 这种一般是由于材质贴图的缺失,一般来说选定的默认贴图的话会打 ...
- (转)最小二乘法拟合圆公式推导及vc实现[r]
(下文内容为转载,不过已经不清楚原创的是哪里了,特此说明) 转自: http://www.cnblogs.com/dotLive/archive/2006/10/09/524633.html 该网址下 ...
- Java的String&StringBuffer&StringBuilder
一:String类 1.String对象的初始化 由于String对象特别用,所以在对String对象进行初始化时,Java提供了一种简化的特殊语法,格式如下: String s = "ab ...
- 【solr基础教程之二】索引
一.向Solr提交索引的方式 1.使用post.jar进行索引 (1)创建文档xml文件 <add> <doc> <field name="id"&g ...
- ASPCMS 多条件查询
1. 表单样例: <form name="topFrm" id="topFrm" action="/search.asp"> & ...
- requirejs学习之-- 初始化(一)
为了规范在项目中使用的javascript代码,我们使用了requirejs框架. 初始阶段,我们在按钮的点击事件中调用创建的模块,代码如下: function button_click() { _t ...
- class A<T>where T
where表明了对类型变量T的约束关系.where T: A表示类型变量是继承于A的,或者是A本身.where T:new()指明了创建T的实例时应该使用的构造函数.
- linux修改文件权限
ubuntu 下修改文件访问权限 Ubuntu下修改目录权限命令如下: chmod 600 name (只有所有者有读和写的权限) chmod 644 name (所有者有读和写的权限,组用户只有读的 ...
- ActionBar-PullToRefreshLibs+沉浸式在部分手机上的布局错乱,目前知道的三星
前段时间看见ActionBar-PullToRefreshLibs用来刷新很好看,配合4.4以上支持的沉浸式效果更佳,于是便想配合沉浸式+ActionBar-PullToRefreshLibs做出一个 ...