pku3668 Game of Lines
http://poj.org/problem?id=3668
水题,STL
#include <stdio.h>
#include <set> using namespace std; set<pair<int, int> > set1; int gcd(int x, int y)
{
return y? gcd(y, x%y): x;
} int abs(int x)
{
return x<? -*x: x;
} struct P
{
int x, y;
}p[]; int main()
{
int n, i, j;
int x, y, gcd_xy;
while(~scanf("%d", &n))
{
set1.clear();
for(i=; i<=n; i++)
{
scanf("%d%d", &p[i].x, &p[i].y);
}
for(i=; i<=n-; i++)
{
for(j=i+; j<=n; j++)
{
x = p[i].x - p[j].x;
y = p[i].y - p[j].y;
if(x < )
{
x *= -;
y *= -;
}
gcd_xy = gcd(abs(x), abs(y));
x /= gcd_xy;
y /= gcd_xy;
if(x == )
{
y = ;
}
if(y == )
{
x = ;
}
//printf("%d %d : %d %d\n", i, j, x, y);
set1.insert(make_pair(x, y));
}
}
printf("%d\n", (int)set1.size());
}
return ;
}
pku3668 Game of Lines的更多相关文章
- extracting lines bases a list using awk
extracting lines bases a list using awk awk 'NR==FNR{a[$1]=$0; next}($1 in a){print a[$1]"\n&qu ...
- Enum:Game of Lines(POJ 3668)
画直线 题目大意:给定一些点集,要你找两点之间的连线不平行的有多少条 数据量比较少,直接暴力枚举,然后放到set查找即可 #include <iostream> #include < ...
- 我的常用mixin 之 lines
/** * 最多显示 $lineCount 行 * lines * * example: * @include lines; * @include lines(3); */ @mixin lines( ...
- uva 1471 defence lines——yhx
After the last war devastated your country, you - as the king of the land of Ardenia - decided it wa ...
- POJ 1269 Intersecting Lines --计算几何
题意: 二维平面,给两条线段,判断形成的直线是否重合,或是相交于一点,或是不相交. 解法: 简单几何. 重合: 叉积为0,且一条线段的一个端点到另一条直线的距离为0 不相交: 不满足重合的情况下叉积为 ...
- POJ 1269 Intersecting Lines【判断直线相交】
题意:给两条直线,判断相交,重合或者平行 思路:判断重合可以用叉积,平行用斜率,其他情况即为相交. 求交点: 这里也用到叉积的原理.假设交点为p0(x0,y0).则有: (p1-p0)X(p2-p0) ...
- [CareerCup] 13.1 Print Last K Lines 打印最后K行
13.1 Write a method to print the last K lines of an input file using C++. 这道题让我们用C++来打印一个输入文本的最后K行,最 ...
- Codeforces 593B Anton and Lines
LINK time limit per test 1 second memory limit per test 256 megabytes input standard input output st ...
- 简单几何(直线位置) POJ 1269 Intersecting Lines
题目传送门 题意:判断两条直线的位置关系,共线或平行或相交 分析:先判断平行还是共线,最后就是相交.平行用叉积判断向量,共线的话也用叉积判断点,相交求交点 /********************* ...
随机推荐
- python流程控制语句 ifelse - 1
考点:条件判断语句if-elif 代码: #! /usr/bin/python print ('\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n') p ...
- mac root用户初始密码设置
具体方法如下: 1)sudo su切换到root,输入的用户密码是当前用户的密码: 2)切换到root后,执行passwd root,设置root用户密码即可.
- opencv 画延长线
hough变换可以让我们检测到直线,这在前面已有详解,对于车道检测,我们需要其到图像边界的延长线一遍之后数据帧分析. 以下代码帮助我们在opencv中画延长线,本来想用虚线表示延长线的,无奈参数调不好 ...
- qtp与selenium2的区别
QTP: 我觉得qtp适合的人: 对编程不是很熟悉的 厌烦了手动的功能测试,想快速进入自动化行业的 公司想快速自动化项目,并且对价格或者对盗版无所谓的 vbs脚本语言易于上手,可以培训你对代码的兴趣 ...
- [HDOJ2586]How far away?(最近公共祖先, 离线tarjan, 并查集)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2586 这题以前做过…现在用tarjan搞一发…竟然比以前暴力过的慢………… 由于是离线算法,需要Que ...
- Android百度地图
帖子 热搜: 二维码 聊天 二维码扫描 传感器 游戏 定位 手势绘图 小项目 相框 绘图 涂鸦 拨打电话 记事本 定时器 通话记录 短信群发 listview 音乐播放器 项目例子 百度地 ...
- linq 之左连接
List<ArticleModel> articleList = articleRepository.GetAllArticle(); List<UsersModel> use ...
- [转帖]Asp.NET 弹出页面
原文链接:http://www.cnblogs.com/adi-liu/archive/2008/07/18/1246091.html ASP.NET 弹出对话框和页面之间传递值的经验总结 今天碰到一 ...
- Java Web编程的主要组件技术——JSP
参考书籍:<J2EE开源编程精要15讲> JSP(Java Server Page)页面由HTML代码和嵌入其中的Java代码组成. 简单的JSP页面如: <html> < ...
- cocos2d-x 滚动文字(二)
http://blog.csdn.net/kuovane/article/details/8131789 首先送上demo,下载地址为:demo下载地址 一,怎么在文字前面空两隔?只需在xml里的文字 ...