hdu 1077 Catching Fish 计算几何+暴力枚举
来源:互联网 发布:双程2网络剧百度云盘 编辑:程序博客网 时间:2024/05/16 09:24
简单的暴力枚举,枚举两个点在圆上,用向量法求下圆心。复杂度o(n^3),但数据量只有300
/*author:jxylang:C/C++university:China,Xidian University**If you need to reprint,please indicate the source***/#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#define INF 1E9using namespace std;double X[301],Y[301];int n,ans;double x,y;inline double c(int i){ return (X[i]-x)*(X[i]-x)+(Y[i]-y)*(Y[i]-y);}int calc()//计数{ int i,ans=0; for(i=0;i<n;i++) { if(c(i)>1.0+1e-8)continue; ans++; } return ans;}void center(int i,int j)//确定圆心{ double x1=X[i]-X[j],y1=Y[i]-Y[j],len,k; double a,b;//单位向量 if(x1==0) a=1,b=0; else if (y1==0) a=0,b=1; else { k=-1/y1*x1; len=sqrt(1+k*k); a=1.0/len; b=k/len; } len=1-(x1*x1+y1*y1)/4; if(len<0)return; len=sqrt(len); x1=(X[i]+X[j])/2.0;y1=(Y[i]+Y[j])/2.0; a*=len;b*=len; x=x1+a;y=y1+b; ans=max(ans,calc()); x=x1-a;y=y1-b; ans=max(ans,calc());}int main(){ int T; int i,j; scanf("%d",&T); while(T--) { scanf("%d",&n); for(i=0;i<n;i++) scanf("%lf%lf",&X[i],&Y[i]); ans=0; for(i=0;i<n;i++) for(j=i;j<n;j++) center(i,j); printf("%d\n",ans); }}
- hdu 1077 Catching Fish 计算几何+暴力枚举
- hdu-1077-Catching Fish-计算几何、枚举圆心
- HDU 1077Catching Fish(简单计算几何)
- hdu 1077 Catching Fish(计算几何)
- HDU--1077--Catching Fish--计算几何
- hdu 1077 Catching Fish 计算几何(圆覆盖)
- HDU--1077[Catching Fish] 枚举圆心
- hdu 1077 Catching Fish
- hdu 1077 Catching Fish
- hdoj1077 Catching Fish(几何题,枚举遍历)
- HDU ACM 1077 Catching Fish
- 110.hdu--1077--Catching Fish
- UVALive 6092 Catching Shade in Flatland --枚举+几何计算
- hdu 3952 计算几何 暴力
- HDU 5533(计算几何+暴力)
- HDU 4445(计算几何+暴力)
- hdu 6055 计算几何+暴力
- Catching Fish
- 黑马程序员_Java网络编程概述
- ActiveMQ 无法启动 提示端口被占用
- hibernate中jcs详解
- 历数那些失败的项目(1)---M...
- JM86中帧内帧间模式的选择(1)
- hdu 1077 Catching Fish 计算几何+暴力枚举
- myeclipse 8.6 安装freemarker插件
- 主题模型及其在文本情感分析中的应用
- 第九周任务-项目一(输出输入流重载)
- xiao
- Missing contentDescription attribute on image
- ACM Steps_Chapter Six_Section2
- Unix实用工具教程:《sed与awk》修订第三版清晰版
- 自定义实现好看的toast