[乱搞] BZOJ 4434 [Cerc2015]Ice Igloos
来源:互联网 发布:黑客社工库软件 编辑:程序博客网 时间:2024/06/11 09:22
#include<cstdio>#include<cstdlib>#include<cmath>#include<algorithm>using namespace std;double r[505][505];double A,B,C;double K,L;int Count(int x,int y1,int y2){ int ret=0; for (int y=y1;y<=y2;y++) ret+=r[x][y]>0.0 && fabs(A*x+B*y+C)<=r[x][y]; return ret;}int main(){ freopen("t.in","r",stdin); freopen("t.out","w",stdout); int n,Q,x,y; double _r; scanf("%d",&n); for (int i=1;i<=n;i++) scanf("%d%d%lf",&x,&y,&_r),r[x][y]=_r; scanf("%d",&Q); while (Q--){ int x1,x2,y1,y2; scanf("%d%d%d%d",&x1,&y1,&x2,&y2); if (x1>x2 || (x1==x2 && y1>y2)) swap(x1,x2),swap(y1,y2); int ret=0; if (x1==x2){ for (int y=y1;y<=y2;y++) ret+=r[x1][y]>0.0; }else if (y1==y2){ for (int x=x1;x<=x2;x++) ret+=r[x][y1]>0.0; }else{ A=(y2-y1)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); B=(x1-x2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); C=-(A*x1+B*y1); K=(double)(y2-y1)/(x2-x1); L=y1-K*x1; int l,r,t; if (y2>y1) { l=y1,r=ceil(K*(x1+1)+L-1e-6); ret+=Count(x1,l,r); for (int x=x1+1;x<x2;x++) { t=r,r=ceil(K*(x+1)+L-1e-6); ret+=Count(x,l,r); l=t-1; } ret+=Count(x2,l,r); }else{ r=y1,l=floor(K*(x1+1)+L+1e-6); ret+=Count(x1,l,r); for (int x=x1+1;x<x2;x++){ t=l,l=floor(K*(x+1)+L+1e-6); ret+=Count(x,l,r); r=t+1; } ret+=Count(x2,l,r); } } printf("%d\n",ret); } return 0;}
0 0
- [乱搞] BZOJ 4434 [Cerc2015]Ice Igloos
- 【CERC2015】【BZOJ4434】Ice Igloos
- [乱搞] BZOJ 4436 [Cerc2015]Kernel Knights
- bzoj 4421: [Cerc2015] Digit Division
- bzoj 4436: [Cerc2015]Kernel Knights
- BZOJ 4451: [Cerc2015]Frightful Formula
- 【bzoj 4451】[Cerc2015]Frightful Formula - 递推
- bzoj 4451: [Cerc2015]Frightful Formula 数学+排列组合
- [杂题] BZOJ 4437 [Cerc2015]Looping Labyrinth
- [链表 杂题] BZOJ 4432 [Cerc2015]Greenhouse Growth
- BZOJ 4435: [Cerc2015]Juice Junctions tarjan
- BZOJ 1257 - 数学题 乱搞
- BZOJ 4236 set乱搞
- Bzoj 4422: [Cerc2015]Cow Confinement(线段树+扫描线)
- 【 bzoj 4452 】 [cerc2015] Export Estimate - 并查集
- [FFT || 递推] BZOJ 4451 [Cerc2015]Frightful Formula
- [并查集 杂题] BZOJ 4452 [Cerc2015]Export Estimate
- [扫描线 线段树] BZOJ 4422 [Cerc2015]Cow Confinement
- Android高手的6个境界
- webService学习之路(二):springMVC集成CXF快速发布webService
- 【转载】C# WinForm程序中使用Unity3D控件
- Python爬虫系列教程
- 【转载】桌面WPF中嵌入Unity3D(Standalone)引擎并实现socket通信
- [乱搞] BZOJ 4434 [Cerc2015]Ice Igloos
- 阴阳师手游御魂怎么强化 御魂强化方法详解
- 欢迎使用CSDN-markdown编辑器
- win7 64位驱动开发 经验(1)
- String转换排序问题
- Unknown host 'android.oa.com'. You may need to adjust the proxy settings in Gradle.
- 进程与虚拟内存空间
- C语言中如何获取时间
- 阿里DataV试水