I tried it with some big numbers, and for some well below 1000000 digits, it took around 0.2s. But that’s on ideone, I don’t know how their servers compare to SPOJ’s.
The problem statement doesn’t say how many test cases there are, but there could be tens, hundreds or thousands.
Looking at the code, I see several conversions between integers and string - that’s got to be relatively slow when you’re working with numbers this big. Can you do without them?