TJU Problem 2101 Bullseye
注意代码中:
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
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的更多相关文章
- TJU Problem 2548 Celebrity jeopardy
下次不要被长题目吓到,其实不一定难. 先看输入输出,再揣测题意. 原文: 2548. Celebrity jeopardy Time Limit: 1.0 Seconds Memory Lim ...
- TJU Problem 2857 Digit Sorting
原题: 2857. Digit Sorting Time Limit: 1.0 Seconds Memory Limit: 65536KTotal Runs: 3234 Accepted ...
- TJU Problem 1015 Gridland
最重要的是找规律. 下面是引用 http://blog.sina.com.cn/s/blog_4dc813b20100snyv.html 的讲解: 做这题时,千万不要被那个图给吓着了,其实这题就是道简 ...
- TJU Problem 1065 Factorial
注意数据范围,十位数以上就可以考虑long long 了,断点调试也十分重要. 原题: 1065. Factorial Time Limit: 1.0 Seconds Memory Limit ...
- TJU Problem 1100 Pi
注: 1. 对于double计算,一定要小心,必要时把与double计算相关的所有都变成double型. 2. for (int i = 0; i < N; i++) //N 不 ...
- TJU Problem 2520 Quicksum
注意: for (int i = 1; i <= aaa.length(); i++) 其中是“ i <= ",注意等号. 原题: 2520. Quicksum Time L ...
- TJU Problem 1090 City hall
注:对于每一横行的数据读取,一定小心不要用int型,而应该是char型或string型. 原题: 1090. City hall Time Limit: 1.0 Seconds Memory ...
- TJU Problem 1644 Reverse Text
注意: int N; cin >> N; cin.ignore(); 同于 int N; scanf("%d\n",&N); 另:关于 cin 与 scanf: ...
- 2101 Problem A Snake Filled
题目描述 “What a boring world!”Julyed felt so bored that she began to write numbers on the coordinate pa ...
随机推荐
- python heapq模块使用
Python内置的heapq模块 Python3.4版本中heapq包含了几个有用的方法: heapq.heappush(heap,item):将item,推入heap >>> it ...
- C# WinForm通用皮肤
最近做一个小项目,是以前的一个旧项目改造升级,添加些新功能需要用到c#来开发, 话说最近2年都在用Qt开发,c#都生疏不少,赶紧捡起来, 看到原来的就知道需要重新设计,所有打算找一款通用皮肤省事 下面 ...
- sys 模块
import sys #环境变量 print(sys.path) #查看已经加载的模块 print(sys.modules) #获取终端调用时的参数 print(sys.argv) #获取解释器的版本 ...
- 启动项目时出现java.io.EOFException异常。
错误: 2018-4-18 10:55:54 org.apache.catalina.session.StandardManager doLoad 严重: IOException while load ...
- tomcat 服务器线程问题
http://blog.csdn.net/wtopps/article/details/71339295 http://blog.csdn.net/wtopps/article/details/713 ...
- mysql 从库执行insert失败导致同步停止
服务配置:一主一从,版本都是 5.5 .主库配置了 binlog-do-db binlog-ignore-db 问题复述:运营人员发现,昨天的数据统计不对.数据分析服务查询的是从库的数据. 到tomc ...
- Java数值类型之间转换
Java之间的数值转换如图所示,实心箭头代表无数据丢失,虚线箭头代表可能丢失 例如:123456789是一个大的整数,包含的位数比float类型能够表达的位数多,但这个数转换为float类型时,将会得 ...
- calc()
width:calc(): cale(a)计算出表达式a的值. e.g: height:cale(100vh-200px):vh,是指CSS中相对长度单位,表示相对视口高度,通常视口长度单位会被分成1 ...
- Docker(1):初体验之应用挂载到容器
需在安装docker的机器上运行,本文机器环境为Win10,目录可根据实际自行修改. 1.首先创建一个目录:D:\docker\ROOT\WEB-INF 2.在D:\docker\ROOT\WEB-I ...
- swiper 支持性
Swiper3 是一款免费以及轻量级的移动设备触控滑块的js框架,使用硬件加速过渡(如果该设备支持的话).主要使用于移动端的网站.移动web apps,native apps和hybrid apps. ...