题意:

给你n次折叠

m个询问

每次询问折叠后,xi,yi有几层

题解:

计算几何

模拟

#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;
int n,m;
double px[],py[],qx[],qy[];
int dcmp(double a,double b)
{
if (fabs(a-b)<=1e-) return ;
if (a<b)return -;
return ;
}
double Cross(double x1,double y1,double x2,double y2)
{
return x1*y2-x2*y1;
}
void calc(double x1,double y1,double x0,double y0,double &retx,double &rety)
{
retx=(x0*(x1*x0+y1*y0)+y0*(x0*y1-x1*y0))/(x0*x0+y0*y0);
rety=(y0*(x1*x0+y1*y0)-x0*(x0*y1-x1*y0))/(x0*x0+y0*y0);
}
int dp(double x,double y,int t)
{
if (!t)
{
if (dcmp(x,100.0)<&&dcmp(x,0.0)>&&dcmp(y,100.0)<&&dcmp(y,0.0)>)
return ;
return ;
}
if (dcmp(Cross(x-px[t],y-py[t],qx[t]-px[t],qy[t]-py[t]),0.0)>=)return ;
else
{
double retx,rety;
calc(x-px[t],y-py[t],qx[t]-px[t],qy[t]-py[t],retx,rety);
retx+=px[t];rety+=py[t];
return dp(x,y,t-)+dp(retx,rety,t-);
}
}
int main()
{
double _x,_y;
scanf("%d",&n);
for (int i=;i<=n;i++)scanf("%lf%lf%lf%lf",&px[i],&py[i],&qx[i],&qy[i]);
scanf("%d",&m);
while (m--)
{
scanf("%lf%lf",&_x,&_y);
printf("%d\n",dp(_x,_y,n));
}
return ;
}

bzoj1074的更多相关文章

  1. [BZOJ1074] [luogu 4036] [JSOI 2008] 火星人 (二分答案+哈希+fhq treap)

    [BZOJ1074] [luogu 4036] [JSOI 2008] 火星人 (二分答案+哈希+fhq treap) 题面 给出一个长度为n的字符串,m个操作,字符串仅包含小写英文字母 操作1:在k ...

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

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

  3. BZOJ1074 [SCOI2007]折纸origami

    我们先看每个点可能从哪些点折过来的,2^10枚举对角线是否用到. 然后再模拟折法,查看每个点是否满足要求. 恩,计算几何比较恶心,还好前几天刚写过一道更恶心的计算几何,点类直接拷过来2333. /** ...

  4. BZOJ第1页养成计划

    嗯,用这篇博客当一个目录,方便自己和学弟(妹?)们查阅.不定期更新. BZOJ1000   BZOJ1001   BZOJ1002   BZOJ1003   BZOJ1004   BZOJ1005   ...

随机推荐

  1. vue - 计算属性、表单输入绑定

    计算属性 computed:{} <!DOCTYPE html> <html> <head> <title></title> </he ...

  2. python基础之函数式编程、匿名函数、内置函数

    一 函数式编程 不修改外部状态. 模仿数学里得函数进行编程. 用函数编程写出得代码相当精简. 可读性比较差. 例子: y=2*x+1 x=1 def test(x): return 2*x+1 tes ...

  3. python模拟websocket握手过程中计算sec-websocket-accept

    背景 以前,很多网站使用轮询实现推送技术.轮询是在特定的的时间间隔(比如1秒),由浏览器对服务器发出HTTP request,然后由服务器返回最新的数据给浏览器.轮询的缺点很明显,浏览器需要不断的向服 ...

  4. loadNibNamed:(NSString *)name owner:(nullable id)owner options:(nullable NSDictionary *)options用法

    1.name xib的名字 owner当前类对象 options初始参数 实际应用: NSArray *nibs = [[NSBundle mainBundle] loadNibNamed:@&quo ...

  5. Callable 和Runnable

    1:Callable ,方法调用会有返回值. private void callableTest throws ExecutionException, InterruptedException { E ...

  6. Spring boot 集成ckeditor

    1:下载ckeditor  4.4.2 full package ,官网没有显示, 需要在最新版本的ckeditor download右键,复制链接, 输入到导航栏,将版本号改为自己想要的版本号. h ...

  7. Spark中文文本分析建模

    实用的朴素贝叶斯模型建模 建模过程主要是把文本转化成向量然后再作分析 数据格式: ,善良 美丽 ,丑陋 阴险 卑鄙 ,温和 ....... 注:前面是给文章贴的标签,后面是文章的分词,分词可以找关于分 ...

  8. POJ2506:Tiling(递推+大数斐波那契)

    http://poj.org/problem?id=2506 #include <iostream> #include <stdio.h> #include <strin ...

  9. HDU:Gauss Fibonacci(矩阵快速幂+二分)

    http://acm.hdu.edu.cn/showproblem.php?pid=1588 Problem Description Without expecting, Angel replied ...

  10. PAT 1114 Family Property[并查集][难]

    1114 Family Property(25 分) This time, you are supposed to help us collect the data for family-owned ...