choosing datatype



L and R are integers 1 ? L ? R ? 10^18, In this case what datatype we can use??


use long long int.

If you’re using scanf/printf for input/output use “%lld” as the control string.


It depends entirely upon the context in which the problem is given.

For example,if the input is very large(10^10000)then you cant take input as integers or long int or long long int(in case of C++) because overflow will occur…In such situation you have to take input as an array of characters…and (if required later on) perform the required manipulation/operation…

In most of the questions…basically input depends upon how you think about the approach/algorithm to a particular problem.


lld limit will exceed 10^18


Excuse me? You mean that LLD_MAX >= 10^18, right?


Also check out the following discussion:

It will be more helpful.


Store the numerical inputs(L and R) as a character array and process it!!


Why? long in Java and long long in C/C++ is ok for those values…


if it exceeds 10^19?


the question is: “L, R <= 10^18”…


Sry for my mistake


Whats up with the down votes!!:o Am I wrong?


No you are correct. Added my +1