you need a third party large integer class, such as provided by boost, to handle huge numbers.
however, every problem like this I have seen has a solution where you don't NEED the numbers 'in hand' to solve it. In fact the point is usually finding the trick to solve it without needing the big values.
why not just ask for the answer directly and have done with it. The trick is the answer... its on you to figure it out if you want to solve the thing. And I don't know, I haven't studied the thing. I am just trying to steer you away from the brute force approach, which is always wrong for CC problems.
@jonnin is absolutely correct
you don't need to put whole question here just ask the problem you are facing.
Well I can help, you can use dynamic input which can take input till memory goes out like biginteger class in java or python lang (by default).
But in this questoin you don't even need these stuffs, you can take input as a string K and typecast when you need. I can't tell you more that's all.