有一个网页游戏,玩玩游戏盒子是I❤U的形状,是什么游戏,有链接吗?

1018人阅读
计算几何-其它(9)
uva 10084 Hotter Colder
Problem E: Hotter Colder
The children's game Hotter Colder is played as follows. Player A leaves the room while player B hides an object somewhere in the room. Player A re-enters at position (0,0) and then visits various other positions about the room. When player A visits a new position,
player B announces "Hotter" if this position is closer to the object than t player B announces "Colder" if it is farther and "Same" if it is the same distance.
Input consists of up to 50 lines, each containing an x,y coordinate pair followed by "Hotter", "Colder", or "Same". Each pair represents a position within the room, which may be assumed to be a square with opposite corners at (0,0) and (10,10). For each line
of input print a line giving the total area of the region in which the object may have been placed, to 2 decimal places. If there is no such region, output 0.00.
Sample Input
10.0 10.0 Colder
10.0 0.0 Hotter
0.0 0.0 Colder
10.0 10.0 Hotter
Output for Sample Input
题目大意:
有一个人玩游戏,起初是个左下角(0,0) 右上角(10,10)的矩形,有一个宝藏藏在这之间。这个人起初在(0,0) 每次走到一个点,会告诉你与原来的点相比距离宝藏近了还是远了,还是不变,根据这个每次求宝藏的范围(面积)。
解题思路:
每次相当于形成一个新的范围是凸包,只需要求这个凸包所有的点,然后按照极角排序,求面积。
这题wa了很多次,感觉代码略麻烦了一点点。代码:
#include &iostream&
#include &cstdio&
#include &cmath&
#include &vector&
#include &string&
#include &sstream&
#include &algorithm&
const double eps=1e-6;
struct point{
double x,y;
point(double x0=0,double y0=0){x=x0;y=y0;}
double getdis(point p){
return double(sqrt((x-p.x)*(x-p.x)+(y-p.y)*(y-p.y)));
double xchen(point p){//this X P
return x*p.y-p.x*y;
friend bool operator & (point a,point b){
if(a.y!=b.y) return a.y&b.y;
else return a.x&b.x;
struct line{//line ax+by+c=0
double a,b,c;
line(double a0=0,double b0=0,double c0=0){a=a0;b=b0;c=c0;}
void setline(point p1,point p2){
a=p1.y-p2.y,b=p2.x-p1.x,c=p1.x*p2.y-p2.x*p1.y;
point getCrossPoint(line l1){//get the cross point of Line l1 and l2
tmp.x=(l1.b*c-b*l1.c)/(l1.a*b-l1.b*a);
tmp.y=(l1.c*a-c*l1.a)/(l1.a*b-l1.b*a);
vector &point&
void ini(){
p.clear();
p.push_back(point(0,0));
p.push_back(point(10,0));
p.push_back(point(10,10));
p.push_back(point(0,10));
line getLine(point p1,point p2){//get the Line that cross point p1 + p2/2
tmpLine.a=p2.x-p1.x;
tmpLine.b=p2.y-p1.y;
tmpLine.c=(p1.x*p1.x-p2.x*p2.x+p1.y*p1.y-p2.y*p2.y)/2.0;
return tmpL
double xchen(point a,point b,point c){
return (b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);
bool cmp(point a,point b){
if(fabs(xchen(p[0],a,b))&eps) return a.getdis(p[0])&b.getdis(p[0]);
else return xchen(p[0],a,b)&0;
void deal(point s,point d,int flag){
line l2=getLine(s,d);
vector &point&
for(int i=0;i&p.size();i++){
if(flag&0){
if(p[i].getdis(s)&p[i].getdis(d)){
v.push_back(p[i]);
if(p[i].getdis(s)&p[i].getdis(d)){
v.push_back(p[i]);
p.push_back(p[0]);
for(int i=1;i&p.size();i++){
l1.setline(p[i-1],p[i]);
if( fabs(l1.a*l2.b-l1.b*l2.a)&eps )
point tmp=l2.getCrossPoint(l1);
if( fabs( fabs(tmp.x-p[i-1].x)+fabs(tmp.x-p[i].x)-fabs(p[i].x-p[i-1].x) ) & eps
if( fabs( fabs(tmp.y-p[i-1].y)+fabs(tmp.y-p[i].y)-fabs(p[i].y-p[i-1].y) ) & eps
v.push_back(tmp);
p.clear();
sort(v.begin(),v.end());
for(int i=0;i&v.size();i++){
if(p.size()&0 && ( fabs(p.back().x-v[i].x)&eps &&
fabs(p.back().y-v[i].y)&eps ) )
p.push_back(v[i]);
if(p.size()&=1) sort(++p.begin(),p.end(),cmp);
double getarea(){
double sum=0;
for(int i=1;i&p.size()-1;i++){
point p1=point(p[i].x-p[0].x,p[i].y-p[0].y);
point p2=point(p[i+1].x-p[0].x,p[i+1].y-p[0].y);
sum+=fabs(p2.xchen(p1))/2.0;
void solve(){
point s(0,0),d;
double area=getarea();
while(cin&&d.x&&d.y&&str){
//if(d.x&-eps || d.y&-eps || d.x&10+eps || d.y&10+eps){
//printf("0.00\n");
if(str=="Colder"){
if(fabs(d.x-s.x)&eps || fabs(d.y-s.y)&eps){
deal(s,d,-1);
area=getarea();
else if(str=="Hotter"){
if(fabs(d.x-s.x)&eps || fabs(d.y-s.y)&eps){
deal(s,d,1);
area=getarea();
printf("%.2lf\n",area);
if(area&eps)
while(cin&&d.x&&d.y&&str){
printf("0.00\n");
int main(){
阅读:7041播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
视频:﹏引領丶湖丠〃 I ❤ U
发送到手机 / 微信 / 朋友圈
请扫描下列二维码
嵌入代码:
*通用代码支持手机播放哦
方式一:扫一扫
支持各类二维码扫描软件
方式二:发一发
免费发送App到手机
请输入正确的手机号码
看不清验证码不正确
该短信不收取任何费用
方式三:下一下
下载App观看
还有更多攻略和游戏礼包等着你
游戏新鲜报
测试状态:(公测)
QQ炫舞本周上升视频
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
播放: 评论:
畅游视频网页游戏YOYO手游
完美游戏台
网络视听许可证

我要回帖

更多关于 在家无聊找个游戏玩玩 的文章

 

随机推荐