Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

WHY RE

Posted by vince4053040 at 2010-02-18 15:41:10 on Problem 1118
In Reply To:什么意思?我也快RE到吐血 Posted by:vince4053040 at 2010-02-18 15:36:20
#include<iostream>
using namespace std;
struct Hole
{
	float row;
	float col;
	int num;
};
Hole hole[702];

int N, sum;

void dfs(float i_row, float i_col, int j, float k, int m)
{
	if(j >= N) return ;
	for(int p = j; p < N; p ++) {
		if(m == 0) {
			if(hole[p].col - i_col == 0)
				sum ++;
		}
		else {  //m == 1
			if(hole[p].col - i_col == 0)
				continue;
			else {
				if((hole[p].row - i_row) / (hole[p].col - i_col) == k)
					sum ++;
			}
		}
	}
	return ;
}

int main()
{
	//freopen("1118in.txt", "r", stdin);
	float k;
	int i, j, gg;
	int total[10000];
	while(cin >> N && N) {
		for(i = 0; i < N; i ++)
			cin >> hole[i].row >> hole[i].col;
		if(N == 1) {
			cout << 1 << endl;
			break;
		}
		gg = 0;
		memset(total, 0, sizeof(total));
		for(i = 0; i < N; i ++) {
			for(j = i + 1; j < N; j ++) {
				sum = 2;
				if(hole[j].col - hole[i].col == 0) {
					dfs(hole[i].row, hole[i].col, j + 1, 0, 0);     //k在此处令为0 无意义
					total[gg ++] = sum;
				}
				else {
					k = (hole[i].row - hole[j].row) / (hole[i].col - hole[j].col);
					dfs(hole[i].row, hole[i].col, j + 1, k, 1);
					total[gg ++] = sum;
				}
			}
		}
		int max = -1;
		for(i = 0; i < gg; i ++) {
			if(total[i] > max) 
				max = total[i];
		}
		cout << max << endl;
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator