poj 1066
来源:互联网 发布:上海政府数据开放平台 编辑:程序博客网 时间:2024/06/05 08:41
本来是计算几何的。。不过数据水。。可以用巧(luan)妙(gao)的方法过掉。
贴代码。
#include<iostream>#include<cstdlib>using namespace std;int geti(int x,int y){if(y==0)return x-1;if(x==100)return 99+y;if(y==100)return 299-x;return 399-y;}int main(){int i=0,n,x0[30],y0[30],x1[30],y1[30],from,to,s[400]={};double x,y,k;for(cin>>n;i<n;i++)cin>>x0[i]>>y0[i]>>x1[i]>>y1[i];cin>>x>>y;for(i=0;i<n;i++){k=(y0[i]-y1[i])/(x0[i]+1e-6-x1[i]);from=geti(x0[i],y0[i]);to=geti(x1[i],y1[i]);if((y-y1[i]>k*(x-x1[i]))-(x0[i]<x1[i]))swap(from,to);for(;from!=to;to=(to+399)%400)s[to]++;}for(i=0;i<400;i++)if(s[i]<n)n=s[i];cout<<"Number of doors = "<<n+1<<endl;return 0;}
0 0
- poj 1066
- poj 1066
- poj 1066
- poj 1066
- poj 1066
- poj 1066
- poj 1066 Treasure Hunt
- POJ 1066 Treasure Hunt
- POJ 1066 Treasure Hunt
- POJ 1066 Treasure Hunt
- poj 1066 Treasure Hunt
- POJ 1066 线段相交
- POJ 1066 Treasure Hunt
- poj 1066 Treasure Hunt
- POJ 1066 Treasure Hunt
- poj 1066 Treasure Hunt
- POJ 1066 Treasure Hunt
- poj 1066 Treasure Hunt
- Libevent源码分析-----Libevent时间管理
- HDU--1195:Open the Lock (一道简单的BFS)
- shell脚本定时任务 ( linux系统)
- 8大排序算法图文讲解
- wait()、sleep()、notify()、notifyAll()、interrupt()、join()、yield() 、interrupted()所属类及其作用分析
- poj 1066
- __weak如何实现对象值自动设置为nil的
- 程序员也要不停学习不停总结
- Eclipse快捷键大全
- Windows sockets网络开发-基本UDP套接字编程
- Mybatis运作流程(手动方式创建sqlSessionFactory)
- Oracle中的Join(连接)的使用
- C++及OpenCV中调用Tesseract
- 如何少走弯路地开发智能硬件?听听“台湾制造”怎么说