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

Plz help me

Posted by ibroker at 2007-10-08 22:53:16 on Problem 3374
I know it is farey sequence.
I precalc all of farey sequences using dfs.
But # of farey sequences(n>=1000) is huge, so it can't.
please help me..

void dfs(pair<int, int> a, pair<int, int> b)
{
	pair<int, int> c;
	c.first = a.first + b.first;
	c.second = a.second + b.second;
	int cc = gcd(c.second, c.first);
	c.first/=cc; c.second/=cc;

	if(c.second<=n)
	{
		dfs(a, c);
		data.push_back(c);
		dfs(c, b);
	}

	return;
}

this is my main solution.
It this wrong? How do I solve this problem? :(

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