# 208.10.23【SCOI2007】【洛谷P4468】【BZOJ1074】折纸origami（点关于直线对称）

13 篇文章 0 订阅

## 解析：

#### 思路：

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define gc getchar
#define pc putchar
#define cs const

inline double getdb(){
re double x,y=1.0;
re char c;
re bool f=0;
while(!isdigit(c=gc()))if(c=='-')f=1;x=c^48;
while(isdigit(c=gc()))x=x*10+(c^48);
if(c!='.')return f?-x:x;
while(isdigit(c=gc()))x+=(y/=10)*(c^48);
return f?-x:x;
}

cs double eps=1e-6;
struct Point{
double x,y;
Point(cs double &_x=0,cs double &_y=0):x(_x),y(_y){}
friend Point operator+(cs Point &a,cs Point &b){return Point(a.x+b.x,a.y+b.y);}
friend Point operator-(cs Point &a,cs Point &b){return Point(a.x-b.x,a.y-b.y);}
friend Point operator*(cs Point &a,cs double &b){return Point(a.x*b,a.y*b);}
friend Point operator/(cs Point &a,cs double &b){return Point(a.x/b,a.y/b);}
friend double operator*(cs Point &a,cs Point &b){return a.x*b.y-b.x*a.y;}
friend double dot(cs Point &a,cs Point &b){return a.x*b.x+a.y*b.y;}
double norm()cs{return sqrt(dot(*this,*this));}
Point reflect()cs{return Point(-y,x)/norm();}
}st[10],ed[10];

inline Point reflect(cs Point &p,cs int &i){
double dist=(st[i]-p)*(ed[i]-p)/(st[i]-ed[i]).norm();
return p-(ed[i]-st[i]).reflect()*2*dist;
}

inline int query(cs Point &p,cs int &now){
if(!now)return p.x>eps&&p.x<100-eps&&p.y>eps&&p.y<100-eps;
if((st[now]-p)*(ed[now]-p)<eps)return 0;
return query(p,now-1)+query(reflect(p,now),now-1);
}

int m,n;
signed main(){
scanf("%d",&n);
for(int re i=1;i<=n;++i){
st[i].x=getdb();
st[i].y=getdb();
ed[i].x=getdb();
ed[i].y=getdb();
}
scanf("%d",&m);
while(m--){
Point p;
p.x=getdb();
p.y=getdb();
printf("%d\n",query(p,n));
}
return 0;
}

• 1
点赞
• 0
收藏
觉得还不错? 一键收藏
• 0
评论
12-11 361
04-15 452
10-23 93
05-11 113

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