You are not logged in. Please login at www.codechef.com to post your questions!

×

choosing datatype

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

asked 03 Nov '12, 22:07

hari_thor's gravatar image

2★hari_thor
61127
accept rate: 0%

1

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

(13 Nov '12, 23:34) hariprasath2★
2

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

(13 Nov '12, 23:36) betlista ♦♦3★
1

if it exceeds 10^19?

(13 Nov '12, 23:40) hariprasath2★
4

the question is: "L, R <= 10^18"...

(13 Nov '12, 23:43) betlista ♦♦3★
2

Sry for my mistake

(13 Nov '12, 23:44) hariprasath2★

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.

link

answered 09 Nov '12, 15:44

abhinav1592's gravatar image

2★abhinav1592
4572713
accept rate: 0%

edited 09 Nov '12, 15:47

1

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

(09 Nov '12, 15:50) abhinav15922★
-1

use long long int.

If you're using scanf/printf for input/output use "%lld" as the control string.

link

answered 03 Nov '12, 23:12

back2basics's gravatar image

2★back2basics
320410
accept rate: 10%

1

lld limit will exceed 10^18

(06 Nov '12, 16:18) hari_thor2★
1

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

(06 Nov '12, 16:20) betlista ♦♦3★

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

(14 Nov '12, 12:26) back2basics2★

No you are correct. Added my +1

(14 Nov '12, 12:30) vinayak garg4★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×57

question asked: 03 Nov '12, 22:07

question was seen: 1,118 times

last updated: 14 Nov '12, 12:30