POJ - 1266 -
题目大意:给出一条圆弧上的两个端点A,B,和圆弧上两端点之间的一个点C,现在要用一块各个定点的坐标均为整数的矩形去覆盖这个圆弧,要求最小的矩形面积。
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100000
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
struct Point
{
double x,y;
Point(double x=,double y=):x(x),y(y) {}
}p[];
typedef Point pointt;
pointt operator + (Point a,Point b)
{
return Point(a.x+b.x,a.y+b.y);
}
pointt operator - (Point a,Point b)
{
return Point(a.x-b.x,a.y-b.y);
}
int dcmp(double x)
{
if(fabs(x)<eps) return ;
else return x<?-:;
}
struct Circle
{
Point center;
double r;
};
double cross(Point a,Point b)
{
return a.x*b.y-a.y*b.x;
}
double mul(Point p0,Point p1,Point p2)
{
return cross(p1-p0,p2-p0);
}
double dis(Point a)
{
return a.x*a.x+a.y*a.y;
}
double area()
{
return fabs(cross(p[]-p[],p[]-p[]))/;
}
bool seginter(pointt a1,pointt a2,pointt b1,pointt b2)
{
double c1 = cross(a2-a1,b1-a1),c2 = cross(a2-a1,b2-a1),
c3 = cross(b2-b1,a1-b1),c4 = cross(b2-b1,a2-b1);
return dcmp(c1)*dcmp(c2)<&&dcmp(c3)*dcmp(c4)<;
}
struct Circle Circumcircle()
{
Circle tmp;
double a,b,c,c1,c2;
double xa,ya,xb,yb,xc,yc;
a = sqrt(dis(p[]-p[]));
b = sqrt(dis(p[]-p[]));
c = sqrt(dis(p[]-p[]));
tmp.r = (a*b*c)/(area()*4.0);
xa = p[].x;
ya = p[].y;
xb = p[].x;
yb = p[].y;
xc = p[].x;
yc = p[].y;
c1 = (dis(p[])-dis(p[]))/;
c2 = (dis(p[])-dis(p[]))/;
tmp.center.x = (c1*(ya-yc)-c2*(ya-yb))/((xa-xb)*(ya-yc)-(xa-xc)*(ya-yb));
tmp.center.y = (c1*(xa-xc)-c2*(xa-xb))/((ya-yb)*(xa-xc)-(ya-yc)*(xa-xb));
return tmp;
}
int main()
{
int i;
double r;
int w0,w1,h0,h1;
for(i = ; i <= ; i++)
scanf("%lf%lf",&p[i].x,&p[i].y);
Circle cc = Circumcircle();
r = cc.r; Point q[];
for(i = ;i < ;i++)
q[i] = cc.center;
q[].x-=r,q[].x+=r,q[].y-=r,q[].y+=r; if(!seginter(q[],p[],p[],p[])) w0 = floor(q[].x+eps);
else w0 = floor(min(p[].x,p[].x)+eps); if(!seginter(q[],p[],p[],p[])) w1 = ceil(q[].x-eps);
else w1 = ceil(max(p[].x,p[].x)-eps); if(!seginter(q[],p[],p[],p[])) h0 = floor(q[].y+eps);
else h0 = floor(min(p[].y,p[].y)+eps); if(!seginter(q[],p[],p[],p[])) h1 = ceil(q[].y-eps);
else h1 = ceil(max(p[].y,p[].y)-eps); printf("%d\n",(h1-h0)*(w1-w0));
return ;
}
POJ - 1266 -的更多相关文章
- poj 1266 Cover an Arc.
http://poj.org/problem?id=1266 Cover an Arc. Time Limit: 1000MS Memory Limit: 10000K Total Submiss ...
- POJ题目细究
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP: 1011 NTA 简单题 1013 Great Equipment 简单题 102 ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
- POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Descr ...
- POJ 3254. Corn Fields 状态压缩DP (入门级)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
随机推荐
- Flask最强攻略 - 跟DragonFire学Flask - 第六篇 Flask 中内置的 Session
Flask中的Session非常的奇怪,他会将你的SessionID存放在客户端的Cookie中,使用起来也非常的奇怪 1. Flask 中 session 是需要 secret_key 的 from ...
- jenkins配置sonarqube
jenkins配置sonarqube 下载插件SonarQube Scanner for Jenkins 在系统管理系统设置中选择 SonarQube servers 配置服务器名称.访问URL地址, ...
- python安装模块方法汇总
方法一: 原文地址: http://blog.csdn.net/cighao/article/details/47860041 在 windows 系统下,只需要输入命令 pip install re ...
- 图片的Base64编码
Base64编码是一种图片处理格式,通过特定的算法将图片编码成一长串字符串,在页面上显示的时候,可以用该字符串来代替图片的url属性. 我们可以来看一下实际的效果 Base64编码效果 在上图中,我们 ...
- 【逆向工具】IDA使用2-VS2015版本release查找main函数入口,局部变量
VS2015版本release查找main函数入口 vc++开发的程序main或WinMain函数是语法规定的用户入口,而不是应用程序入口.入口代码是mainCRTstartup.wmainCRTSt ...
- f-GAN
学习总结于国立台湾大学 :李宏毅老师 f-GAN: Training Generative Neural Samplers using Variational Divergence Minimizat ...
- zabbix3.0.4报错Get value from agent failed: cannot connect to [[1.1.1.1]:10050]: [4] Interrupted syste
一.问题描述 部署完Zabbix agent之后,Server无法获取到数据.报错.报错信息如下: Get value from agent failed: cannot connect to [[1 ...
- flexible array柔性数组、不定长的数据结构Struct详解
柔性数组,这个名词对我来说算是比较新颖的,在学习跳跃表的实现时看到的.这么好听的名字,的背后到底是如何的优雅. 柔性数组,其名称的独特和迷惑之处在于“柔性”这个词.在C/C++中定义数组,是一个定长的 ...
- Java8实战系列一
从java7到java8,最主要的变化可以总结为 □Lambda表达式 □ 方法引用 □流和默认方法 让我们通过一个小例子感受一下 情景 1 集合对象排序 (对list中的苹果按照重量排序) Coll ...
- LeetCode(36): 有效的数独
Medium! 题目描述: 判断一个 9x9 的数独是否有效.只需要根据以下规则,验证已经填入的数字是否有效即可. 数字 1-9 在每一行只能出现一次. 数字 1-9 在每一列只能出现一次. 数字 1 ...