How to deal with huge data types

I am very noob in programming and since my school days, i used to work with integers only in C.
Most of the problems here in CodeChef have testcases reaching to long long int values.
I can think of the problem with integers, code them and find the answers good, but when I submit it, i see either a wrong answer or, time limit exceeded. This actually frustrates me a bit, since I know my logic is no bad, it’s just that I am unable to manipulate the code with bigger data types.
I am working hard to get over to this, but sometimes, it is disappointing watching me nowhere in the contest results.
If anybody has a suggestion for me, thanks in advance.

Firstly for competetive programming C++ is better than C because of the presence of STL.
Now coming to the data types if the value to be stored is small then you can use int as the data type…EG: to accept the no of trail cases which is in the range 10^4 or something you can use int…Even we can use long int for this case…There is nothing wrong in using the data type as long int…And if we need to store values above 10^5 or something then it is better that we use long long int or double…Even if i say like this you may not get it…You will automatucally choose the right data type by practice…

For more information check this one out!


1 Like


Just to add to that @bipin2 said, you might need to add some specific size identifiers:

Long int:
long int i = 0L;

Long long int:
long long int x = 0LL;

Unsigned long long int:
unsigned long long int j = 0ULL;

I guess these identifiers are important, especially when you are calculating things like running sums or running products…