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包裹的元素是一个 ...
随机推荐
- iOS开发 ~应用程序设计理念:视图控制器(UIViewController)、视图(UIView)
应用程序设计理念:视图控制器(UIViewController).视图(UIView) 利用视图控制器(底层)管理视图(外观),一对一 1.视图的作用:负责显示的外观 2.视图控制器的作用:创建界面. ...
- UINavigationController 导航控制器
一.导航视图控制器 1.管理视图控制器 2.控制视图控制器之间的跳转 3.是以压栈和出栈的形式来管理视图控制器 4.导航视图控制器必须要设置根视图控制器 5.导航是视图控制器包含UINavigatio ...
- java调试一
Eclipse 平台的特色在于内置了 Java 调试器,该调试器提供所有标准调试功能,包括进行单步执行.设置断点和值.检查变量和值以及暂挂和恢复线程的能力.Eclipse 平台工作台(Eclipse ...
- 关于LayoutParams
每一个布局均有一个叫LayoutParams的内部类,如: LinearLayout.LayoutParams RelativeLayout.LayoutParams AbsoluteLayout ...
- mysql之主从复制
原理--> 在数据库层面,复制语句或者行,因为在数据库层面,故只有主服务器生成,并放到二进制日志里面,才能复制给从服务器. 原理--> mysql的主从复制基于异步,主要有三个进程执行,分 ...
- djangoPOST请求403 forbidden
处理过程 网上搜索修改setting.py,在MIDDLEWARE_CLASSES增加django.middleware.csrf.CsrfResponseMiddleware 没能解决问题 有说在 ...
- SRAM与SDRAM的比较(转)
原文:http://blog.csdn.net/fg8181/article/details/2278100 内存在电脑中起着举足轻重的作用,一般采用半导体存储单元,包括随机存储器(RAM),只读存储 ...
- MSSQL WITH (NOLOCK) 脏读
缺点: 1.会产生脏读 2.只适用与select查询语句 优点: 1.有些文件说,加了WITH (NOLOCK)的SQL查询效率可以增加33%. 2.可以用于inner join 语句 脏读: 一个用 ...
- UESTC_Ferris Wheel String 2015 UESTC Training for Search Algorithm & String<Problem L>
L - Ferris Wheel String Time Limit: 3000/1000MS (Java/Others) Memory Limit: 43000/43000KB (Java/ ...
- LeeCode-Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number. The ...