# [BZOJ1074][计算几何][搜索]SCOI2017：折纸

4 篇文章 0 订阅
2 篇文章 0 订阅

OJ挂，链自找

Code：

#include<bits/stdc++.h>
#define eps 1e-6
#define db double
using namespace std;
int res=0,f=1;char ch=getchar();
while(!isdigit(ch)) {if(ch=='-') f=-f;ch=getchar();}
while(isdigit(ch)) {res=(res<<1)+(res<<3)+(ch^48);ch=getchar();}
return res*f;
}
const int N=2e5+5;
struct point{
db x,y;
point(){}
point(db _x,db _y):x(_x),y(_y){}
friend inline point operator + (const point &a,const point &b){return point(a.x+b.x,a.y+b.y);}
friend inline point operator - (const point &a,const point &b){return point(a.x-b.x,a.y-b.y);}
friend inline point operator * (const point &a,const db &b){return point(a.x*b,a.y*b);}
friend inline point operator / (const point &a,const db &b){return point(a.x/b,a.y/b);}
friend inline db operator * (const point &a,const point &b){return a.x*b.y-a.y*b.x;}
inline db dis(){return sqrt(x*x+y*y);}
inline point ref(){return point(-y,x)/dis();}
}p1[N],p2[N];
inline point ref(point p,int id){
db dis=(p1[id]-p)*(p2[id]-p)/(p1[id]-p2[id]).dis();
return p-(p2[id]-p1[id]).ref()*2*dis;
}
int dfs(point p,int now){
if(!now) return p.x>eps && p.x+eps<100 && p.y>eps && p.y+eps<100;
if((p1[now]-p)*(p2[now]-p)<eps) return 0;
return dfs(p,now-1)+dfs(ref(p,now),now-1);
}
int main(){
for(int i=1;i<=n;i++)
scanf("%lf%lf%lf%lf",&p1[i].x,&p1[i].y,&p2[i].x,&p2[i].y);
while(q--){
db x,y;
scanf("%lf%lf",&x,&y);
cout<<dfs(point(x,y),n)<<"\n";
}
return 0;
}

• 0
点赞
• 0
收藏
觉得还不错? 一键收藏
• 0
评论
04-29 1297
06-01 3126
01-08 99
02-17 110
03-13 450

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、付费专栏及课程。