swustoj轰炸(0129)

来源:互联网 发布:支付宝在淘宝购物流程 编辑:程序博客网 时间:2024/04/25 22:43

“我该怎么办?”飞行员klux向你求助。 事实上,klux面对的是一个很简单的问题,但是他实在太菜了。 klux要想轰炸某个区域内的一些地方,它们是位于平面上的一些点,但是(显然地)klux遇到了抵抗,所以klux只能飞一次,而且由于飞机比较破,一点起飞就只能沿直线飞行,无法转弯。现在他想一次轰炸最多的地方。 不限定起飞地点

Description

输入数据由n对整数组成(1<n<700),每对整数表示一个点的坐标。没有一个点会出现两次。 

Input

一个整数,表示一条直线能覆盖的最多的点数。

Output
1
2
3
4
5
6
5
1 1
2 2
3 3
9 10
10 11
Sample Input
1
3
Sample Output
/*水题:直接暴力可以过*/#include <stdio.h>#include <string.h>#include<iostream>#include<stack>#include<algorithm>using namespace std;int main(){int n;int x[1000], y[1000];cin >> n;for (int i = 0; i < n; i++){scanf("%d %d", &x[i], &y[i]);}int ans = 2;int temp = 2;for (int i = 0; i < n; i++){for (int j = i + 1; j < n; j++){temp = 2;double xx, yy;xx = x[i] - x[j];yy = y[i] - y[j];for (int k = j + 1; k < n; k++){double xxx, yyy;xxx = x[k] - x[j];yyy = y[k] - y[j];if ((xx / xxx) == (yy / yyy)){temp++;}}ans = max(ans, temp);}}cout << ans << endl;return 0;}

0 0
原创粉丝点击