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


problem with large inputs

guys help me out here ,whenever there is an input that is order of 10^6 or 10^9 my compiler says runtime error..when i check the solution like in the 'ODD' problem one guy has used character array and then converted them into integers...i mean how do i handle large inputs

asked 06 Jun '12, 14:24

topazbravo's gravatar image

accept rate: 0%

add some simple code that end with runtime error

(06 Jun '12, 14:27) betlista ♦♦3★

why are you posting the same question twice??

(06 Jun '12, 15:01) ashhar244★

It is more easy when you go for python.If it is c there is an algorithm to handle it mostly we handle it using char for more information read the links

This answer is marked "community wiki".

answered 17 Sep '16, 01:20

saimurali333's gravatar image

accept rate: 0%

In problem ODD, you are getting Runtime Error most probably because you are using too much memory by declaring an array of size 10^9.There is not enough memory in your machine(even online judges have a limit on memory your program uses) to accommodate an array of that size. Read this: Ideally, try to declare an array of size less than or equal to 10^7 and that too globally because in some cases array of size 10^7 in any function may exceed stack size and give an error. BTW in the question you mentioned it's not even necessary to declare array of any size


answered 17 Sep '16, 05:25

yougaindra's gravatar image

accept rate: 0%

edited 17 Sep '16, 20:13

if the inputs are very large , say order of 10^9 or 10^10 and if you perform some opeartions on these numbers such as addition or multiplication then it is possible that the resulting number may be very large , say order of 10^15 or 10^20. in that case you should take the number as string and then perform operation on strings. very large numbers can be easily stored in string formats. You could also use BigInteger class in java for handling such numbers. This could possibly resolve the runtime error !


answered 06 Apr '17, 12:25

karan10xb's gravatar image

accept rate: 0%

For values of order 10^6 or 10^9 then you can use long or long long or unsigned long long. This will help you.But of order greater than 10^15 u need to take that input as a string.


answered 06 Apr '17, 13:44

lagnam's gravatar image

accept rate: 0%

toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 06 Jun '12, 14:24

question was seen: 2,981 times

last updated: 06 Apr '17, 13:44