我们先看每个点可能从哪些点折过来的,2^10枚举对角线是否用到。

然后再模拟折法,查看每个点是否满足要求。

恩,计算几何比较恶心,还好前几天刚写过一道更恶心的计算几何,点类直接拷过来2333。

 /**************************************************************
Problem: 1074
User: rausen
Language: C++
Result: Accepted
Time:24 ms
Memory:980 kb
****************************************************************/ #include <cstdio>
#include <cmath>
#include <algorithm> using namespace std;
typedef double lf; const int N = ;
const lf eps = 1e-; int n, cnt; inline lf sqr(lf x) {
return x * x;
} inline int dcmp(lf x) {
return fabs(x) <= eps ? : (x > eps ? : -);
} struct point {
lf x, y;
point() {}
point(lf _x, lf _y) : x(_x), y(_y) {} inline point operator + (point p) {
return point(x + p.x, y + p.y);
}
inline point operator - (point p) {
return point(x - p.x, y - p.y);
}
inline lf operator * (point p) {
return x * p.y - y * p.x;
}
inline lf operator % (point p) {
return x * p.x + y * p.y;
}
inline point operator * (lf a) {
return point(x * a, y * a);
}
inline point operator / (lf a) {
return point(x / a, y / a);
} inline bool operator < (const point &p) const {
return dcmp(x - p.x) == ? dcmp(y - p.y) < : dcmp(x - p.x) < ;
}
inline bool operator != (const point &p) const {
return dcmp(x - p.x) || dcmp(y - p.y);
}
inline bool operator == (const point &p) const {
return !dcmp(x - p.x) && !dcmp(y - p.y);
} inline void read_in() {
scanf("%lf%lf", &x, &y);
}
friend inline lf dis2(point p) {
return sqr(p.x) + sqr(p.y);
}
friend inline lf dis(point p) {
return sqrt(dis2(p));
}
friend inline lf angle(point p, point q) {
return acos(p % q / dis(p) / dis(q));
}
friend inline point rotate(point p, lf A) {
lf s = sin(A), c = cos(A);
return point(p.x * c - p.y * s, p.x * s + p.y * c);
}
} ans[N << ]; struct line {
point p, v;
line() {}
line(point _p, point _v) : p(_p), v(_v){}
} l[N]; inline point reverse(point p, line l, int f) {
return l.p + rotate(p - l.p, angle(p - l.p, l.v) * * f);
} inline bool on_left(point p, line l) {
return dcmp((p - l.p) * l.v) < ;
} inline bool on_right(point p, line l) {
return dcmp((p - l.p) * l.v) > ;
} void dfs(point p, int d) {
ans[++cnt] = p;
if (d == ) return;
dfs(p, d - );
if (on_left(p, l[d])) dfs(reverse(p, l[d], -), d - );
} inline bool check(lf x) {
return dcmp(x) > && dcmp(x - ) < ;
} inline bool check(point p) {
return check(p.x) && check(p.y);
} inline point find(point p) {
int i;
for (i = ; i <= n; ++i)
if (on_right(p, l[i])) p = reverse(p, l[i], );
else if (!on_left(p, l[i])) return point(-, -);
return p;
} int work(point p) {
int res = , i;
cnt = ;
dfs(p, n);
sort(ans + , ans + cnt + );
cnt = unique(ans + , ans + cnt + ) - ans - ;
for (i = ; i <= cnt; ++i)
if (check(ans[i]) && find(ans[i]) == p) ++res;
return res;
} int main() {
int i, Q;
point x, y;
scanf("%d", &n);
for (i = ; i <= n; ++i) {
x.read_in(), y.read_in();
l[i] = line(x, y - x);
}
scanf("%d", &Q);
while (Q--) {
x.read_in();
printf("%d\n", work(x));
}
return ;
}

BZOJ1074 [SCOI2007]折纸origami的更多相关文章

  1. 【BZOJ】1074: [SCOI2007]折纸origami

    http://www.lydsy.com/JudgeOnline/problem.php?id=1074 题意:一开始有一个左上角是(0,100),右下角是(100,0)的纸片,现在可以沿有向直线折n ...

  2. 1074: [SCOI2007]折纸origami - BZOJ

    Description 桌上有一张边界平行于坐标轴的正方形纸片,左下角的坐标为(0,0),右上角的坐标为(100,100).接下来执行n条折纸命令.每条命令用两个不同点P1(x1,y1)和P2(x2, ...

  3. 1074: [SCOI2007]折纸origami

    Time Limit: 20 Sec  Memory Limit: 162 MBSubmit: 372  Solved: 229[Submit][Status][Discuss] Descriptio ...

  4. 【题解】折纸 origami [SCOI2007] [P4468] [Bzoj1074]

    [题解]折纸 origami [SCOI2007] [P4468] [Bzoj1074] 传送门:折纸 \(\text{origami [SCOI2007] [P4468]}\) \(\text{[B ...

  5. CSS3写折纸

    <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...

  6. 折纸问题java实现

    /** * 折纸问题 这段代码写的太low了 本人水平有限 哎... 全是字符串了 * @param n * @return * @date 2016-10-7 * @author shaobn */ ...

  7. CSS3实现文字折纸效果

    CSS3实现文字折纸效果 效果图: 代码如下,复制即可使用: <!DOCTYPE html> <html> <head> <title></tit ...

  8. UVA 177 PaperFolding 折纸痕 (分形,递归)

    著名的折纸问题:给你一张很大的纸,对折以后再对折,再对折……每次对折都是从右往左折,因此在折了很多次以后,原先的大纸会变成一个窄窄的纸条.现在把这个纸条沿着折纸的痕迹打开,每次都只打开“一半”,即把每 ...

  9. ZR#955 折纸

    ZR#955 折纸 解法: 可以发现折纸之后被折到上面的部分实际上是没有用的,因为他和下面对应位置一定是一样的,而影响答案的只有每个位置的颜色和最底层的坐标范围.因此,我们只需要考虑最底层即可,即我们 ...

随机推荐

  1. RPN网络

    Region Proposal Network RPN的实现方式:在conv5-3的卷积feature map上用一个n*n的sliding window(论文中n=3)生成一个长度为256(ZF网络 ...

  2. Navigation Nightmare---poj1984(多关系并查集)

    题目链接:http://poj.org/problem?id=1984 给定n个城市,m条边告诉你城市间的相对距离,接下来q组询问,问你在第几条边添加后两城市的距离. #include <ios ...

  3. 无题II---hdu2236(二分,匈牙利)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2236 要求最大值与最小值的差值最小,是通过枚举边的下限和上限来完成 只需要用二分找一个区间,然后不断枚 ...

  4. Navicat连接服务器上的Mysql数据库

  5. Struts2表单数据接收方式

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/sunshoupo211/article/details/30249239 1.将Action类作 ...

  6. linux 如何查看防火墙是否开启

    service iptables status可以查看到iptables服务的当前状态.但是即使服务运行了,防火墙也不一定起作用,你还得看防火墙规则的设置 iptables -L在此说一下关于启动和关 ...

  7. 认识与设计Serverless(二)

    一.设计Serverless的功能模块 第一节讲了Serverless一些概念与特性,废话居多,概念的东西了解过后要有设计与构思,才能学到精髓,一个Serverless平台的形成,涉及到很多模块的架构 ...

  8. ZOHO 免费小型企业邮箱和个人邮箱

    Zoho Mail 提供免费小型企业邮箱注册.精简版只能添加一个域到您的机构帐号,最多允许10用户.如果您想添加多个域,您可以升级到标准版.10用户免费,5 GB /每用户,5 GB (共享). 除了 ...

  9. java基础类型中的char和byte的辨析及Unicode编码和UTF-8的区别

    在平常工作中使用到char和byte的场景不多,但是如果项目中使用到IO流操作时,则必定会涉及到这两个类型,下面让我们一起来回顾一下这两个类型吧. char和byte的对比 byte byte 字节, ...

  10. 38初识xml

    XML(可扩展标记语言)是一种用于记录多种数据类型的标记语言.使用XML可以将各类型的文档定义为容易读取的格式,便于用户读取.而且,在应用程序中使用XML,可以轻松实现数据交换. QT中提供两种访问X ...