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 ...
Search found 15 matches
- Sat Jan 31, 2004 8:12 pm
- Forum: General
- Topic: Test Case Generator and Answer
- Replies: 12
- Views: 4907
- Sat Jan 31, 2004 5:56 pm
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 317994
- Sat Jan 31, 2004 5:46 pm
- Forum: General
- Topic: Test Case Generator and Answer
- Replies: 12
- Views: 4907
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 ...
- Sat Jan 31, 2004 2:28 pm
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 317994
- Fri Jan 30, 2004 5:10 am
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 317994
- Fri Jan 30, 2004 5:07 am
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 317994
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 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 ...
- Thu Jan 29, 2004 4:44 pm
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 317994
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 ...
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 ...
- Thu Jan 29, 2004 12:33 pm
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 317994
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 ...
[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 ...
- Thu Jan 29, 2004 12:20 pm
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 317994
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 ...
- Thu Jan 29, 2004 7:46 am
- Forum: C++
- Topic: Very surprising
- Replies: 3
- Views: 2519
- Thu Jan 29, 2004 12:48 am
- Forum: Volume 1 (100-199)
- Topic: 102 - Ecological Bin Packing
- Replies: 485
- Views: 116656
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 ...
[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 ...
- Thu Jan 29, 2004 12:19 am
- Forum: C++
- Topic: automatic header inclusion
- Replies: 4
- Views: 3128
- Thu Jan 29, 2004 12:12 am
- Forum: C++
- Topic: a[++y]=a[y]+1;
- Replies: 15
- Views: 6287
- Wed Jan 28, 2004 11:53 pm
- Forum: C++
- Topic: Weird problem with debugger in MS visual C++
- Replies: 11
- Views: 5362
- Wed Jan 28, 2004 11:44 pm
- Forum: C++
- Topic: Weird problem with debugger in MS visual C++
- Replies: 11
- Views: 5362