I believe the problem lies in Turbo C++ 3.0, IIRC that's an early 90's compiler and may be 16-bit. For a 16-bit integer the range of values it can hold is [-32768, 32767], in the cases you mention the result is bigger than that, for example, Case 3 is 250721.
I recommend you use this week and a half, before the next round, to test newer compilers. Microsoft offers Visual C++ Express Edition for free, I haven't tried version 2010 but version 2008 is what I use and I like it, specially it's debugging capabilities. If you try this one, create a "Win32 Console Project" then in the dialog options select "Empty Project" and then add your source file. This is to avoid VC creating a precompiled header which will be useless for competitions purposes and may lead to send a non compiling solution if you forget to include the header. http://www.microsoft.com/express/downloads/ <http://www.microsoft.com/express/downloads/>Also, you can (and should) try some of the open source alternatives, I'll mention only 2 since are the ones I know the most, but maybe someone else jumps in and recommends another, listen to them too. Dev-C++ is a full IDE, it uses gcc as a compiler and Cygwin or MinGW. http://sourceforge.net/projects/dev-cpp/ Eclipse has a C/C++ version, I've never tried it, but Eclipse for Java is great and have heard many people recommending it for C++ as well. http://www.eclipse.org/cdt/ Or you can simply try to install MinGW or Cygwin to get the GNU compiler (gcc) and do the coding in a lightweight text editor. Although this will require a bit more of learning if you have never done any command line compiling. http://www.mingw.org/ http://www.cygwin.com/ <http://sourceforge.net/projects/dev-cpp/>If you want to use a full IDE, I strongly recommend you try Visual C++, Dev-C++ and Ecplise. Take two or three problems you already know how to solve, and solve them again in each of the environments and see in which you feel most comfortable in, lets call it X. Now, you have decided to use X, keep practicing the rest of the week using X to get more comfortable compiling, debugging, testing and whatever you can think of in it. In order to be prepared to do your coding painlessly during the online round Good luck, hope this works for you, Carlos Guía On Tue, May 25, 2010 at 7:31 AM, Amitesh Purwar <[email protected]>wrote: > I am using Turbo C++ Version 3.0 on Windows 7(32bit). Still i got the > problems in case of large output every time i compile the program. In case > of this output, I compared with your one and found that the problem occurs > in case of large no.s such as of Case 3, Case 5, Case 6 etc. > > What should I do to remove such type of errors? > > > On Tue, May 25, 2010 at 6:13 AM, Carlos Guia <[email protected]> wrote: > >> >> I uploaded both small and large output files I get using your code, with a >> minimal modification, I had to change the includes. >> >> You had >> >>> #include<stdio.h> >> >> #include<conio.h> >> >> #include<process.h> >> >> #include<fstream.h> >> >> >> I changed it to >> >>> #include<stdio.h> >> >> #include<conio.h> >> >> #include<process.h> >> >> #include<fstream> >> >> using namespace std; >> >> >> >> That shouldn't change the outcome since you didn't even use any class from >> fstream in this code, but with your includes I had compilation errors >> thrown. I believe <fstream.h> is deprecated, and you shouldn't add ".h" for >> c++ STL headers. I tried to find a source stating that, the closest is this, >> from http://www.sgi.com/tech/stl/Vector.html, if you go to "Definition" >> it reads. >> >> Defined in the standard header vector<http://www.sgi.com/tech/stl/vector>, >>> and in the nonstandard backward-compatibility header >>> vector.h<http://www.sgi.com/tech/stl/vector.h> >> >> >> So those STL ".h" files are some old nonstandard files, I would try to >> keep myself away from them if possible. >> >> I didn't upload them to GCJ practice room, but I "compared"(quick >> look) them with mine and both seem correct. Moreover, I think the code is >> correct. >> >> In order to be a little bit more helpful in avoiding such issues in the >> future I need to know a few things. >> - What compiler (name and version) are you using? >> - What operating system (most importantly 32 or 64 bit system)? Or even if >> it is 16 bit? I hope not. >> >> Hope it helps, >> Carlos Guía >> >> >> >> On Mon, May 24, 2010 at 6:18 PM, Amitesh Purwar < >> [email protected]> wrote: >> >>> Thank you for response. >>> >>> But I would like to tell you that the same problem occurs in my code when >>> i execute problem B of the qualification round. Could you please attached >>> the output of my code which comes in your system. >>> >>> On Tue, May 25, 2010 at 3:10 AM, Carlos Guia <[email protected]> wrote: >>> >>>> In my computer it has no difference, thought it may in some systems, but >>>> the standard format for "long int" is "%ld". In my computer long and int >>>> are >>>> both 32 bits long so there's no difference, maybe on a 64-bit system long >>>> is >>>> 64 bits long and there is. Other than that I don't see how that code could >>>> give negative results, unless c is overflowing, but seems unlikely. >>>> >>>> Carlos Guía >>>> >>>> >>>> On Sun, May 23, 2010 at 7:57 AM, Amitesh Purwar < >>>> [email protected]> wrote: >>>> >>>>> Hello, >>>>> I am a newbie in the programming contest. I was looking through >>>>> the xdliutao(rank 4) code and i found that it gives the same output as my >>>>> code. The output does contain some negative values which result in >>>>> cancellation of my code. Do you guys suggest me....that is there a problem >>>>> exists in my code or my machine? >>>>> >>>>> and this is not the first time for me that my code outputs garbage >>>>> value.:) >>>>> >>>>> -- >>>>> Thanks & Regards, >>>>> >>>>> Amitesh Purwar. >>>>> >>>>> Twitter : http://bit.ly/jQfDo >>>>> facebook : http://bit.ly/xIlCn >>>>> >>>>> Contact No. :- +91-9718418621 >>>>> >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "google-codejam" group. >>>>> To post to this group, send email to [email protected]. >>>>> To unsubscribe from this group, send email to >>>>> [email protected]<google-code%[email protected]> >>>>> . >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/google-code?hl=en. >>>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "google-codejam" group. >>>> To post to this group, send email to [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]<google-code%[email protected]> >>>> . >>>> For more options, visit this group at >>>> http://groups.google.com/group/google-code?hl=en. >>>> >>> >>> >>> >>> -- >>> Thanks & Regards, >>> >>> Amitesh Purwar. >>> >>> "Accept the Challenges to feel the exhilaration of Victory." >>> >>> >>> Twitter : http://bit.ly/jQfDo >>> facebook : http://bit.ly/xIlCn >>> orkut : http://bit.ly/RXG6e >>> linkedin : http://bit.ly/YbfZZ >>> >>> >>> Contact No. :- +91-9718418621 >>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "google-codejam" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]<google-code%[email protected]> >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/google-code?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "google-codejam" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<google-code%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/google-code?hl=en. >> > > > > -- > Thanks & Regards, > > Amitesh Purwar. > > "Accept the Challenges to feel the exhilaration of Victory." > > Twitter : http://bit.ly/jQfDo > facebook : http://bit.ly/xIlCn > orkut : http://bit.ly/RXG6e > linkedin : http://bit.ly/YbfZZ > > Contact No. :- +91-9718418621 > > > -- > You received this message because you are subscribed to the Google Groups > "google-codejam" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-code%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-code?hl=en. > -- You received this message because you are subscribed to the Google Groups "google-codejam" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-code?hl=en.
