博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
P2665 [USACO08FEB]连线游戏Game of Lines
阅读量:4332 次
发布时间:2019-06-06

本文共 1043 字,大约阅读时间需要 3 分钟。

不平行就是直线斜率不同

枚举所有两点的斜率,对平行坐标轴的线特殊考虑

离散化一下就好了

#include
#include
#include
#include
#include
using namespace std;inline int read(){ int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); } return x*f;}const int N=4e4+7;const double INF=2e9+7;int n,pos[207][2],cnt,ans;double k[N];int main(){ n=read(); for(int i=1;i<=n;i++) pos[i][0]=read(),pos[i][1]=read(); for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) { cnt++; if(pos[i][0]==pos[j][0]) { k[cnt]=INF; continue; } if(pos[i][1]==pos[j][1]) { k[cnt]=0; continue; } k[cnt]=(double)(pos[i][1]-pos[j][1])/(double)(pos[i][0]-pos[j][0]); } sort(k+1,k+cnt+1); ans=1; for(int i=2;i<=cnt;i++) if(k[i]!=k[i-1]) ans++; printf("%d",ans); return 0;}

 

转载于:https://www.cnblogs.com/LLTYYC/p/9864714.html

你可能感兴趣的文章
一般处理程序在VS2012中打开问题
查看>>
C语言中的++和--
查看>>
thinkphp3.2.3入口文件详解
查看>>
POJ 1141 Brackets Sequence
查看>>
Ubuntu 18.04 root 使用ssh密钥远程登陆
查看>>
Servlet和JSP的异同。
查看>>
虚拟机centOs Linux与Windows之间的文件传输
查看>>
ethereum(以太坊)(二)--合约中属性和行为的访问权限
查看>>
IOS内存管理
查看>>
middle
查看>>
[Bzoj1009][HNOI2008]GT考试(动态规划)
查看>>
Blob(二进制)、byte[]、long、date之间的类型转换
查看>>
OO第一次总结博客
查看>>
day7
查看>>
iphone移动端踩坑
查看>>
vs无法加载项目
查看>>
Beanutils基本用法
查看>>
玉伯的一道课后题题解(关于 IEEE 754 双精度浮点型精度损失)
查看>>
《BI那点儿事》数据流转换——百分比抽样、行抽样
查看>>
哈希(1) hash的基本知识回顾
查看>>