×

# problem with large inputs

 0 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 1●1●2●2 accept rate: 0% add some simple code that end with runtime error (06 Jun '12, 14:27) why are you posting the same question twice?? (06 Jun '12, 15:01) ashhar244★

 0 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 http://gd.tuwien.ac.at/languages/c/programming-bbrown/c_055.htm http://www.azillionmonkeys.com/qed/userInput.html link This answer is marked "community wiki". answered 17 Sep '16, 01:20 1●1 accept rate: 0%
 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: http://stackoverflow.com/questions/216259/is-there-a-max-array-length-limit-in-c 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 91●3 accept rate: 0%
 0 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 11 accept rate: 0%
 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 1★lagnam 1 accept rate: 0%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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:

×678
×169
×30

question asked: 06 Jun '12, 14:24

question was seen: 2,981 times

last updated: 06 Apr '17, 13:44