[gcj] Re: Round 1B 2008 - Number sets

2009-09-08 Thread Miguel Oliveira
No. You have to write the code yourself. If you understand the code. You'll be able to write it from scratch easily ;)Check http://en.wikipedia.org/wiki/Disjoint-set_data_structure On Sep 8, 12:51 am, Satyajit Malugu malugu.satya...@gmail.com wrote: I think that it's harder to do it that

[gcj] Re: Round 1B 2008 - Number sets

2009-09-08 Thread Miguel Oliveira
The No was meant to which I think uses this Union find mechanism.. Those Set classes allows you to insert, delete or find in an efficient way, mas not merging which is what this problem is really about. On Sep 8, 9:49 am, Miguel Oliveira mr.miguel.olive...@gmail.com wrote: No. You have to write

[gcj] Re: Round 1B 2008 - Number sets

2009-09-08 Thread Miguel Oliveira
Ops, the last frase should be but not merging which is what this problem is really about. On Sep 8, 10:57 am, Miguel Oliveira mr.miguel.olive...@gmail.com wrote: The No was meant to which I think uses this Union find mechanism.. Those Set classes allows you to insert, delete or find in an

[gcj] Re: Round 1B 2008 - Number sets

2009-09-07 Thread gislan
On Mon, 7 Sep 2009 16:57:11 -0400, Prolific Coder prolific.co...@gmail.com wrote: Now for case 2 - 10 20 3 output is given as 7. Can some one explain how is it? I am getting it as 8. [cut] 12 - 2*2*3 15 - 3*5 Set 1 - 10, 15, 20 Set 2 - 12, 18 Set 3-8 - 11, 13, 14, 16, 17,19 12 share

[gcj] Re: Round 1B 2008 - Number sets

2009-09-07 Thread Satyajit Malugu
So is it like finally we should have all the numbers with prime factor higher than P (in this case 3) should be in one setand rest constitutes individual sets? From the problem statement - If the two integers share a prime factor which is at least *P*, then you merge the two sets to which the

[gcj] Re: Round 1B 2008 - Number sets

2009-09-07 Thread Miguel Oliveira
I think that it's harder to do it that way. Do you know how to do those set merge operations efficiently? On Sep 7, 11:19 pm, Satyajit Malugu malugu.satya...@gmail.com wrote: So is it like finally we should have all the numbers with prime factor higher than P (in this case 3) should be in one

[gcj] Re: Round 1B 2008 - Number sets

2009-09-07 Thread Satyajit Malugu
I think that it's harder to do it that way. Do you know how to do those set merge operations efficiently? From the contest analysis its union find (graph operation) Set operations can be done efficiently in C++ STL sets or java Set which I think uses this Union find mechanism. I will try to