从后往前逆推
const int N = 10; struct Point { DB Ox, Oy; Point(){} Point(DB _Ox, DB _Oy) : Ox(_Ox), Oy(_Oy) {} friend Point operator -(Point a, Point b) { return Point(a.Ox-b.Ox, a.Oy-b.Oy); } friend Point operator + (Point a, Point b){ return Point(a.Ox + b.Ox, a.Oy + b.Oy); } DB Len() { return sqrt(Ox * Ox + Oy * Oy); } friend Point operator /(Point a, DB c) { return Point(a.Ox/c, a.Oy/c); } friend Point operator * (Point a, DB c) { return Point(a.Ox * c, a.Oy * c); } } P[1 << N]; struct Line { Point P1, P2; } Dat[N]; bool Hash[1 << N]; int n, m; inline void Solve(); inline void Input() { scanf("%d", &n); For(i, 1, n) scanf("%lf%lf%lf%lf", &Dat[i].P1.Ox, &Dat[i].P1.Oy, &Dat[i].P2.Ox, &Dat[i].P2.Oy); scanf("%d", &m); } inline DB Cross(Point a, Point b, Point c) { return(b.Ox - a.Ox) * (c.Oy - a.Oy) - (b.Oy - a.Oy) * (c.Ox - a.Ox); } inline DB Dist(Point P1, Point P2) { DB Ox = P1.Ox - P2.Ox, Oy = P1.Oy - P2.Oy; return sqrt(Ox * Ox + Oy * Oy); } inline DB Dist(Point P, Line Dat) { return fabs(Cross(P, Dat.P1, Dat.P2)) / Dist(Dat.P1, Dat.P2); } inline Point Get(Point P, Line Dat) { Point A = Dat.P2 - Dat.P1; Point B(A.Oy, -A.Ox); DB h = Dist(P, Dat); B = B / B.Len() * h; return P + B * 2; } inline bool In(Point P) { return P.Ox > 0 && P.Ox < 100 && P.Oy > 0 && P.Oy < 100; } inline void Solve() { while(m--) { int Cnt = 1; clr(Hash, 0); scanf("%lf%lf", &P[1].Ox, &P[1].Oy); Ford(i, n, 1) { int t = Cnt; For(j, 1, t) if(!Hash[j]) { if(Cross(Dat[i].P1, Dat[i].P2, P[j]) > 0) P[++Cnt] = Get(P[j], Dat[i]); else Hash[j] = 1; } } int Ans = 0; For(i, 1, Cnt) Ans += (!Hash[i] && In(P[i])); printf("%d\n", Ans); } } int main(){ #ifndef ONLINE_JUDGE SETIO("1074"); #endif Input(); Solve(); return 0; }
相关推荐
八中OJ,又简作BZOJ,以原题巨多而著称,该数据为BZOJ上的1000-1109和1130-1139的测试数据节点,没有题目,有需要题目的可以到https://hydro.ac/d/bzoj/p网站查找对应的题目。
BZOJ原题-BZOJP1000-P2000的题目,下载后可以离线做题。
本模板为 BZOJ3224:文艺平衡树 的源程序 含各种操作,旋转,插入,删除,求前驱,后继,查询值为x的数的排名,查询排名为k的数,求最大值,最小值……
「BZOJ1053」反素数/「Violet5」樱花 详细题解
bzoj部分数据.
BZOJ原题-BZOJP3001-P4000的题目,下载后可以离线做题。
BZOJ3230相似子串的测试数据,希望能够帮到大家。
BZOJ网站镜像,对于经常挂掉的BZOJ真是刷题必备啊!
BZOJ平台全部代码,解压到一个文件夹在打开使用。BZOJ平台全部代码,解压到一个文件夹在打开使用。
BZOJ原题-BZOJP2001-P3000的题目,下载后可以离线做题。
BZOJ原题-BZOJP4001-P4406的题目,下载后可以离线做题。
bzoj1878数据(莫队)详细题解:http://blog.csdn.net/boyxiejunboy/article/details/50611972
BZOJ省选十连测题面,只有题面!!!!!,请自行到BZOJ上进行提交,上传目的是提供离线的一个题目
题解 , 文档 , 资料 BZOJ 泡泡堂
ZOJCH是BZOJ题库的离线版
#BZOJ Problem Rankrank.cpp 程序文件data.dat bzoj题库数据done.dat AC过的题,初始可以把所有A过的题粘进去,正常退出的话自动维护。black.dat 黑名单。选题时会跳过。错题、神题、没题面、不想做等等。//Thank ...
CreationAugust 的BZOJ代码合集 【Written by CreationAugust】
八中OJ所有题目
CTSC 2011 无穷图的桥(BZOJ 2307) 题解.ppt
bzoj FFT 的模版