choosing datatype

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

2 Likes

use long long int.

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

1 Like

lld limit will exceed 10^18

1 Like

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

1 Like

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.

2 Likes

Also check out the following discussion:
http://discuss.codechef.com/questions/3408/large-inputs-in-c

It will be more helpful.

1 Like

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

1 Like

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

2 Likes

if it exceeds 10^19?

1 Like

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

4 Likes

Sry for my mistake

2 Likes

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

No you are correct. Added my +1

//