Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Plz help meI 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator