POJ1118 HDU1432 Lining Up
来源:互联网 发布:android 监听网络断开 编辑:程序博客网 时间:2024/05/17 07:04
问题链接:POJ1118 HDU1432 Lining Up。
题意简述:输入n,输入n个整数对,即n个坐标点,问最多共线点数是多少。
问题分析:用暴力法解决这个问题,好在计算规模不算大。
程序中,判断共线时,使用的是乘法,没有用除法,可以保证精确的计算结果。
AC的C语言程序如下:
/* POJ1118 HDU1432 Lining Up */#include <stdio.h>#define MAXN 700struct { int x, y;} p[MAXN]; /* point */int main(void){ int n, ans, max, i, j, k; while(scanf("%d", &n) != EOF && n != 0) { for(i=0; i<n; i++) scanf("%d%d", &p[i].x, &p[i].y); ans = 2; for(i=0; i<n; i++) for(j=i+1; j<n; j++) { max = 2; for(k=j+1; k<n; k++) if ((p[j].x - p[i].x)*(p[k].y - p[j].y) == (p[j].y - p[i].y)*(p[k].x - p[j].x)) max++; if(max > ans) ans = max; } printf("%d\n", ans); } return 0;}
1 0
- POJ1118 HDU1432 Lining Up
- poj1118(Lining Up)
- POJ1118 Lining up
- POJ1118 Lining Up 计算几何
- hdu1432 Lining Up --判断点在一条线上的个数
- POJ1118,Lining Up,暴力过的,hash什么的只能仰慕
- hdu1432
- poj 1118 Lining Up
- pku 1118 Lining Up
- poj 1118 Lining Up
- 1118 Lining Up
- POJ 1118 Lining Up
- poj 1118 Lining Up
- poj 1118 Lining Up
- UVa 270 - Lining Up
- UVa 270 - Lining Up
- uva 270 - Lining Up
- UVa 270 - Lining Up
- 这个是自己的第一篇博客,从现在开始自己就已经走出了校园,正式成为了一名即将工作的程序员了
- 数据库事务
- FOJ 1012 Relatives(欧拉值)
- 初学射极跟随器2
- 字节流与字符流的区别详解
- POJ1118 HDU1432 Lining Up
- HDU1556
- 读《About Face 4 交互设计精髓》3
- iOS深入学习(Block全面分析)
- mysql复合语句、存储过程、游标
- lightoj1058 && poj1791 求平行四边形个数
- URAL 2018 The Debut Album DP中滚动数组用法
- 阿里陶宝技术架构产品(OceanBase&CoBar)
- 控制器中view的创建方式小结