How to handle an input string of length 10^5 in Chef tree problem?

i have done the question using long long int but how to handle an input string of length 10^5 ??
should i overload all mathematical operators for calculation of numbers represented in string format or there is an easy way out ??

Well, there is no easy way out.

Let’s call the number of digits D.
You can implement plus and minus in : O(D) using very-known algorithm from primary school
And you can implement multiplying in : O(D log D) by Russian Gardeners’ Algorithm.
Funny name, but in my language we are using it(check it out here).
Dividing and modulo is hard. Try not to use it. (It can be done using binary search.)

This big numbers are called Bignums in informatics. Bignums on wikipedia
Remember that keeping those numbers on std::strings is not very good idea,
better keep them on vector of long longs. It just means that you keep the number in base64.

@stasszczesniak what if the string has all the elements of char type?

//