Enormous Inputs

+1 Akhilesh Chobey · November 21, 2015
In programming problems, how to tackle the large input conditions.

For e.g. 

The input begins with the number t of test cases in a single line (t<=10). In each of the next t lines there are two numbers m and n (1 <= m <= n <= 1000000000, n-m<=100000) separated by a space.
How do I define these integers?

Post a Reply


Oldest  Newest  Rating
0 Akhilesh Chobey · November 23, 2015
Hey Erky.
The objective of the program is basically to print prime numbers between given two input numbers.
I had asked this question in the forum which was cleared :)

So the input is not manual. An online judge tests our code.
Accordingly they have given constraints for the inputs.
0 Akhilesh Chobey · November 22, 2015
It isn't a manual input. Something like online judge which tests our program.
0 c student · November 22, 2015
signed ints go from -2^31 to 2^31-1 which should be large enough to hold the biggest value which you mentioned to be 1000000000.
0 Eryk Humberto Oliveira Alves · November 22, 2015
sorry I didn't get the example..
Can you write an algorithm for us? :-) Or the objective of the program.

Are you referring to the size of the input variables?

The value of an int can vary between -2.147.483.647 and 2.147.483.647.
The value of an an unsigned long int can vary between 0 and 4.294.967.295. (You call it %li instead of %i or %d).

If want a "larger capacity". Use a real value. Have the input referencing it as a real value (not integer) but when you print it, you print without the decimal values (choose between float %f, or double %lf). The precision is sooooo much higher. To print a float value without the fractional part, do it like that:

double number1 = 56789345654398765432456789765432.6789;
float number2 = 76543456765434565436543.345;
printf("Numbers %.lf \n %.f",number1,number2);

0 Akhilesh Chobey · November 22, 2015
What do you mean by signed ints? Can you please mention the syntax in code?
Also what is long long int ?
  • 1



One of the most popular languages of all time.

Bucky Roberts Administrator