Search found 15 matches

by Farqaleet
Sat Jan 31, 2004 8:12 pm
Forum: General
Topic: Test Case Generator and Answer
Replies: 12
Views: 2685

Some easy to go code with Scruff's sample inputs

Here is some handy code I wrote for my self when I used Scruff's input files as my sample tests. I hope that this will come handy to many. Thanx scruff, your inputs really helped me get the problems right as I had the right data to test for. :D [cpp] /* Use cin and cout as you normally do in your pr...
by Farqaleet
Sat Jan 31, 2004 5:56 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 181975

I think I know why the judge is rejecting your program. You are not looking out for spaces at the start of the input. Put some code that skips over spaces. A better way to do it is to use [cpp] isspace(aux ); [/cpp] as it skips over spaces, tabs, \r, \n etc. Really any kind of a character representi...
by Farqaleet
Sat Jan 31, 2004 5:46 pm
Forum: General
Topic: Test Case Generator and Answer
Replies: 12
Views: 2685

Hey Scruff. Can you please either reduce the size of the downloadables or put the source on the website. I think that you are putting debug versions on the web. Please produce some release versions so that the size is reduced comsiderably. below 100 kb is good enough. Half an MB is way too big for a...
by Farqaleet
Sat Jan 31, 2004 2:28 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 181975

I don't see anything wrong with the logic. If you are getting the wrong answer reply from the judge then there can only be one thing wrong. You are assuming three things. One that the the character set that the judge's computer is using has: '0' - '9' as consecutive characters. Two, that they are in...
by Farqaleet
Fri Jan 30, 2004 5:10 am
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 181975

Sorry for the typo above. :lol: Here is what does work
[cpp]
while(scanf("%d %d",&i,&j) != 0)
[/cpp]
by Farqaleet
Fri Jan 30, 2004 5:07 am
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 181975

You are right. I didn't think of that. Thanx for the help. :) I confused it with another question that did give 0 0 as the ending input. But I don't think that the second one should work either. The reason is that scanf returns the number of inputs read, not what was read. I haven't tested it but I ...
by Farqaleet
Thu Jan 29, 2004 4:44 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 181975

I found out why the first one is accepted by the judge. The reason is that rather than handling the stdin directly, the judge simply redirects stdin to a file so when we read, it reads from a file. So when the EOF character of the file is encountered, the while loop exits. But EOF = 0 so the second ...
by Farqaleet
Thu Jan 29, 2004 12:33 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 181975

Try this to improve your time

I don't know why it takes more time. Remove the condition [cpp] curNumber > 100 [/cpp] In a loop of a million, this will take more processing than it will without it. I have used the same learning technique using recursive decent rather than iterative. It gave me 0.131. see if you can gain some poin...
by Farqaleet
Thu Jan 29, 2004 12:20 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 181975

Strange input problem...

Please can anybody tell me why the judge accepts the first one but doesn't accept the second one and gives a time-limit exceeded error. While on my computer with MSVC++ compiler it's exactly the opposite; the first one runs fine while in the second case time is exceeded because the loop doesn't exit...
by Farqaleet
Thu Jan 29, 2004 7:46 am
Forum: C++
Topic: Very surprising
Replies: 3
Views: 1994

Well if you use gcc then the easiest way to minimize your compile errors is to give the
-ansi
argument to the compiler so it uses less functions and you are limited to the almost the set of functions that the judge uses itself.
by Farqaleet
Thu Jan 29, 2004 12:48 am
Forum: Volume 1 (100-199)
Topic: 102 - Ecological Bin Packing
Replies: 485
Views: 42231

How to insert asm into C/C++ code

It's no trade secret. All you have to do is to enclose it like this: [cpp]_asm nop;[/cpp] for single statement. Or make a block for multiple statements [cpp]_asm { }[/cpp] As C and C++ code can be almost directly converted to asm so the compilers don't have much trouble including any other asm code....
by Farqaleet
Thu Jan 29, 2004 12:19 am
Forum: C++
Topic: automatic header inclusion
Replies: 4
Views: 2505

try using g++ rather than gcc
by Farqaleet
Thu Jan 29, 2004 12:12 am
Forum: C++
Topic: a[++y]=a[y]+1;
Replies: 15
Views: 4825

Following is what MSDN says "In the prefix form, the increment or decrement takes place before the value is used in expression evaluation..." By this the increment is done before y is used anywhere in the expression. That's what microsoft says. but then again you can't say anthing otherwise without ...
by Farqaleet
Wed Jan 28, 2004 11:53 pm
Forum: C++
Topic: Weird problem with debugger in MS visual C++
Replies: 11
Views: 3983

I am sorry. The correction I wanted to suggest was: [cpp]si[(strchr(tem,' ')-tem)] = 0; [/cpp] not si[tem+1]=0; Also as [cpp]tem += strlen(si);[/cpp] is after return thus, the infinite loop. Remember strlen uses null terminator to determine length. If you don't be careful of having null at the end, ...
by Farqaleet
Wed Jan 28, 2004 11:44 pm
Forum: C++
Topic: Weird problem with debugger in MS visual C++
Replies: 11
Views: 3983

Yes the problem is quite strange to even many experience people. Well here it is in some detail char* = A non-const pointer to non-const memory. Both are modifiable const char* = A non-const pointer to a memory locatio that is const i.e. You can modify the pointer but not the memory it points to. ch...

Go to advanced search