注意代码中:

  result1 << " to " << result2 << ", PLAYER 1 WINS."<< endl;

  result1 << " to " << result2 << ", PLAYER 1 WINS. "<< endl;

虽然只在WINS后只差一个空格,但会导致PE。

原题:

2101.   Bullseye


Time Limit: 1.0 Seconds   Memory Limit: 65536K
Total Runs: 3848   Accepted Runs: 1306

Problem

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
partially 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: r2 = x2 + y2 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.

Source: Greater New York
2004

源代码:

 #include <iostream>
#include <string.h>
const int maxn = ;
using namespace std; double score[maxn]; int sCount (double i, double j) {
double temp = i*i + j*j;
if (temp <= ) return ;
else if (temp <= && temp > ) return ;
else if (temp <= && temp > ) return ;
else if (temp <= && temp > ) return ;
else if (temp <= && temp > ) return ;
else return ;
}
int main()
{
memset(score, , sizeof(score));
while (cin >> score[] && score[] != -) {
for (int i = ; i < ; i++) {
cin >> score[i];
}
int result1 = , result2 = ;
result1 += sCount(score[], score[]) + sCount(score[], score[])
+ sCount(score[], score[]);
result2 += sCount(score[], score[]) + sCount(score[], score[])
+ sCount(score[],score[]);
if (result1 > result2) cout << "SCORE: "<<
result1 << " to " << result2 << ", PLAYER 1 WINS."<< endl;
else if (result2 > result1) cout << "SCORE: "<<
result1 << " to " << result2 << ", PLAYER 2 WINS."<< endl;
else cout << "SCORE: "<< result1 << " to " << result2 << ", TIE." << endl;
}
return ;
}

TJU Problem 2101 Bullseye的更多相关文章

  1. TJU Problem 2548 Celebrity jeopardy

    下次不要被长题目吓到,其实不一定难. 先看输入输出,再揣测题意. 原文: 2548.   Celebrity jeopardy Time Limit: 1.0 Seconds   Memory Lim ...

  2. TJU Problem 2857 Digit Sorting

    原题: 2857.   Digit Sorting Time Limit: 1.0 Seconds   Memory Limit: 65536KTotal Runs: 3234   Accepted ...

  3. TJU Problem 1015 Gridland

    最重要的是找规律. 下面是引用 http://blog.sina.com.cn/s/blog_4dc813b20100snyv.html 的讲解: 做这题时,千万不要被那个图给吓着了,其实这题就是道简 ...

  4. TJU Problem 1065 Factorial

    注意数据范围,十位数以上就可以考虑long long 了,断点调试也十分重要. 原题: 1065.   Factorial Time Limit: 1.0 Seconds   Memory Limit ...

  5. TJU Problem 1100 Pi

    注: 1. 对于double计算,一定要小心,必要时把与double计算相关的所有都变成double型. 2. for (int i = 0; i < N; i++)         //N 不 ...

  6. TJU Problem 2520 Quicksum

    注意: for (int i = 1; i <= aaa.length(); i++) 其中是“ i <= ",注意等号. 原题: 2520.   Quicksum Time L ...

  7. TJU Problem 1090 City hall

    注:对于每一横行的数据读取,一定小心不要用int型,而应该是char型或string型. 原题: 1090.   City hall Time Limit: 1.0 Seconds   Memory ...

  8. TJU Problem 1644 Reverse Text

    注意: int N; cin >> N; cin.ignore(); 同于 int N; scanf("%d\n",&N); 另:关于 cin 与 scanf: ...

  9. 2101 Problem A Snake Filled

    题目描述 “What a boring world!”Julyed felt so bored that she began to write numbers on the coordinate pa ...

随机推荐

  1. 洛谷U36590搬书

    题目背景 陈老师喜欢网购书籍,经常一次购它个百八十本,然后拿来倒卖,牟取暴利.前些天,高一的新同学来了,他便像往常一样,兜售他的书,经过一番口舌,同学们决定买他的书,但是陈老师桌上的书有三堆,每一堆都 ...

  2. python3 get/post/使用代理/自定义header/自定义Cookie

    说明:urllib发送http请求并不是很人性化,更推荐使用在urllib基础上封装的.python2和python3都兼容的requests模块,移步查看. 一.get请求 get请求就是在构造Re ...

  3. Web应用的统一异常处理(二十四)

    我们在做Web应用的时候,请求处理过程中发生错误是非常常见的情况.Spring Boot提供了一个默认的映射:/error,当处理中抛出异常之后,会转到该请求中处理,并且该请求有一个全局的错误页面用来 ...

  4. 使用web3+solc编译发布以太坊智能合约

    一.环境安装: 1.安装web3工程:npm install web3 2.安装solc工程:npm install solc二.在node环境中使用 先引用所需环境: var fs = requir ...

  5. javascript void函数

    <a href="javascript:doTest2();void(0);">here</a> 但这儿的void(0)究竟是何含义呢? Javascrip ...

  6. 跨域 jsonp 和 CORS 资料

    http://mp.weixin.qq.com/s/iAShnqvsOyV-Xd0Ft7Nl2Q HTML5安全:CORS(跨域资源共享)简介...ie67不要想了... http://www.cnb ...

  7. 快递小哥逆袭自传:用了6年时间做到了IT部门主管

    在我30岁生日那天,终于收到升职的通知,自己如愿的也从一名小小程序员升职成为IT主管,负责公司硬件设备驱动程序开发项目,工资也从原来月薪10K变到现在月薪20K.或许对于很多人而言,在三十岁的时候,可 ...

  8. 枚举类返回Map键值对,绑定到下拉框

    有时候,页面的下拉框要显示键值对,但是不想从数据库取,此时我们可以写一个枚举类, Java后台代码 1.枚举类 import java.util.HashMap; import java.util.M ...

  9. 给Win32 GUI程序增加控制台窗口的方法

    给Win32 GUI程序增加控制台窗口的方法 2008年10月11日 星期六 下午 04:43 在Win32的GUI程序中,没有控制台窗口,我们输出调试信息时有些不方便,以往我的做法是使用Messag ...

  10. system的消息队列实例

    1\创建或打开消息队列函数原型:int msgget(key_t key, int msgflg)参数第一个参数为ftok方法创建的一个kety_t或者为一个整数值第二个参数为逻辑控制,IPC_CRE ...