"The Solution Problem" - How to get credit for your work as an undergrad?
Worrying about someone taking credit for your work is very common among amateurs and people just starting out, but in my experience is far less common with more experienced researchers. I'm not really sure exactly what the reason for this is, but I have encountered this phenomenon numerous times. I would venture that it is perhaps because those with more experience in the field know how uncommon it is for one person to essentially steal another's results. Most people are relatively good, or at worst benign, and wouldn't dream of taking credit for work they haven't contributed to. Couple that with the fact that being caught plagiarizing someone else's work would be career suicide, and you can be pretty confident that no one you talk to is likely to write up your idea and pass it off as their own.

As Suresh says, you could always upload it to the arxiv, but I would be inclined not to do this, as if it turns out that the work is not novel or there is a major error, then you cannot actually delete the paper, but rather will have to post a retraction, and the original will still be there for all to see. Even now, I still ask colleagues to check any paper I consider relatively important before uploading a manuscript.

If I were you, I would be inclined to talk to one of my lecturers in the first instance, as they can probably give you a feel for whether your solution is novel (and correct), and if it meets both of these criteria, they should be able to give you an idea of how best to proceed. Alternatively, you could just post it as a question here, asking if the result was previously known, or if anybody could point you to a good survey paper on the problem. You'd have a time stamp from the post time, so you wouldn't have to worry about that. If you got an encouraging response here (i.e. that it was not currently known), then you could consider how to proceed from there. If on the other hand, it was already known, or there was a flaw, then it wouldn't really matter.

Technically, you could also simply write it up and submit it to a journal. As Dave says, no one involved in the process will actually know your level (the first time, it's kind of a kick when you get the correspondence addressed to you as either Dr. or Professor), unless one of the reviewers happens to know you personally. However, I would not suggest doing so. You need to search the literature to make sure your idea is actually novel, and as Dave mentions, the writing of papers is an art in and of itself. You would probably need to read a lot of journal articles to even get the style right.