Publishing an idea that came up on a conference? Some weeks ago I went to a conference with some of the leading minds in my field of research. One of the speakers (professor A) mentioned a problem that bothered him and that was unsolved up to that point. After the talk (when most had already left the room to get coffee) professor B mentioned a possible algorithm to A to solve these kind of problems (myself and some others followed the discussion with interest).

Out of interest in the topic and motivated by the prospect of a novel algorithm, I spent some time working on this question myself - combined the suggestion of professor B with some of my own ideas and indeed found an algorithm that solves the problem. I can even proof convergence, error bounds, etc. The suggestion of professor B was enough for a working algorithm, but I think that convergence and correctness proofs are only possible with the addition of my ideas.

The question is how to proceed now. If I had thought of the initial idea myself it would be obvious that I should write it up and get it published. As it stands I obviously have to get in touch with professor B (and professor A?) though.

Is it too presumptuous to propose a collaborative paper to professor B? Should I also contact professor A? I can assume that he at least also worked on the same problem these past few weeks...
I could just mention them in the acknowledgment part of the paper - but that would still feel like I stole their idea.

I could just write them, what my ideas are on the topic - but I would feel more comfortable doing so if they already communicated a will to collaborate with me. As it stands they don't even know I worked on the issue...
On the other hand if I write something along the line of "I have found something. If you are willing to collaborate I will share it with you." it feels somewhat like extortion...

Is there some etiquette how to handle this situation or is it just "first come first serve", and I should see that I get the results published? (OK, the latter is definitely rude - but still...)
You should definitely get in touch with Prof B, but don't propose a collaboration immediately (that would indeed be a little bit presumptuous). 

Thank him for his idea during the conference, and tell him some outline of your results (you may want to share the paper if you feel comfortable). And then end the email with something like "given that the origin of the idea was initially yours, I was wondering how you felt about a possible co-authorship? If you feel that this is not possible, would you mind if I put forward your name in the acknowledgments section?"

That way you leave the choice up to him, and he can have an easy way out if he doesn't feel like being a co-author for any reason.

(EDIT: Regarding Prof A, it might be good etiquette to get in touch with him to make sure he's not working on the same stuff, but I don't think it's strictly necessary)