单项选择题

I spent half an hour ______ this difficult math problem.

A.having worked on
B.to work on
C.on work
D.working on