Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

果然。。。真够恶心的。之前想到>-0.005要输出0.00。。。结果还是不够。。。

Posted by KatrineYang at 2016-09-25 23:16:42 on Problem 1375 and last updated at 2016-09-25 23:16:54
In Reply To:跪舔啊, 数据太坑爹了。。 Posted by:3141592654ly at 2012-08-12 16:01:26
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
using namespace std;

struct intv{
	double s, e;
}intvs[505];

bool compare(const intv& i1, const intv& i2){
	return (i1.s<i2.s) || (abs(i1.s-i2.s)<1e-8 && i1.e<i2.e);
}

double mx(double a, double b){
	return (a>b)? a : b;
}

double clear(double d){
	if(d>=0) return d+1e-8;
	if(d>-0.005+1e-8) return 0;
	return d-1e-8;
}

int main() {
	//printf("%.2lf %.2lf\n", -0.0049, -0.005);
	int gs;
	while(1){
		scanf("%d", &gs);
		if(!gs) return 0;
		int bx, by;
		scanf("%d%d", &bx, &by);
		int cnt = 0;
		for(int i = 0; i < gs; i++){
			int cx, cy, r;
			scanf("%d%d%d", &cx, &cy, &r);
			if(r<=0) continue;
			double ka = atan2(by-cy+0.0, bx-cx+0.0);
			double ap = asin(r*1.0/sqrt((bx-cx)*(bx-cx)+(by-cy)*(by-cy)+0.0));
			double zuoj = ka-ap, youj = ka+ap;
			intvs[cnt].s = bx - cos(zuoj)/sin(zuoj)*by;
			intvs[cnt].e = bx - cos(youj)/sin(youj)*by;
			cnt++;
		}
		sort(intvs, intvs+cnt, compare);
		double st = intvs[0].s, ed = intvs[0].e;
		int idx = 0;
		while(idx < gs){
			if(intvs[idx].s < ed+1e-8){
				ed = mx(ed, intvs[idx].e);
			}
			else{
				printf("%.2lf %.2lf\n", clear(st), clear(ed));
				st = intvs[idx].s, ed = intvs[idx].e;
			}
			idx++;
		}
		printf("%.2lf %.2lf\n\n", clear(st), clear(ed));
	}
	return 0;
}


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator