Search found 1242 matches

by mf
Mon Jan 03, 2011 7:48 pm
Forum: Volume 5 (500-599)
Topic: 583 - Prime Factors
Replies: 171
Views: 34332

Re: 583 - Prime Factors

scanf may return 0 or -1 on failure. So this line is wrong:
while(scanf("%ld",&n)){
You must check that scanf returns 1 here.
by mf
Sun Nov 21, 2010 1:57 am
Forum: Volume 100 (10000-10099)
Topic: 10055 - Hashmat the Brave Warrior
Replies: 166
Views: 43470

Re: 10055 - Hashmat the Brave Warrior

Yes, you may read all the input before printing the output, if you'd like.
But it's more usual to just read and solve the test cases one-by-one.
by mf
Wed Nov 10, 2010 1:10 pm
Forum: Volume 10 (1000-1099)
Topic: 1055 - Pockets
Replies: 3
Views: 5729

Re: First Java prog submission Compilation Error

Your class should be called Main.
by mf
Fri Nov 05, 2010 6:28 pm
Forum: Volume 100 (10000-10099)
Topic: 10055 - Hashmat the Brave Warrior
Replies: 166
Views: 43470

Re: cannot the understand the mistake

Yes.

On a 32-bit OS (which UVa judge uses), "unsigned long int" is an unsigned 32-bit integer, and so it can't represent 2^32, which is a possible input in this problem.
by mf
Fri Nov 05, 2010 2:55 am
Forum: Volume 100 (10000-10099)
Topic: 10055 - Hashmat the Brave Warrior
Replies: 166
Views: 43470

Re: cannot the understand the mistake

No, it ain't.
by mf
Tue Oct 05, 2010 9:20 pm
Forum: Other words
Topic: Do there exist any RE reports?
Replies: 2
Views: 3091

Re: Do there exist any RE reports?

I haven't used the judge for a while, but previously they only reported which Unix signal killed your program. E.g. SIGSEGV, SIGFPE (floating point exception), SIGABRT (call to abort()), etc. But JVM doesn't crash in this way, so RE means just that JVM exited with a non-zero exit code. No other deta...
by mf
Sat Oct 02, 2010 5:39 pm
Forum: Algorithms
Topic: Circular String Linearization
Replies: 12
Views: 12767

Re: Circular String Linearization

Sorry for delay.
I've put most of my ACM ICPC-related stuff here - http://github.com/infnty/acm/
My old team notebook is at http://github.com/infnty/acm/raw/master ... tebook.pdf
by mf
Tue Sep 07, 2010 10:50 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 168349

Re: problem 100 runtime error!!!

Do not use files. You are supposed to read from standard input (java's System.in) and write to standard output.
by mf
Sat Sep 04, 2010 4:43 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 168349

Re: 100 The 3n + 1 problem Time limit exceeded

No, that shouldn't be a problem. A straightforward code without memoization is intended to pass.

I think the error is here - "while (scanf("%d %d", &i, &j))". It must be "while (scanf("%d %d", &i, &j) == 2)".
by mf
Mon Aug 30, 2010 11:53 pm
Forum: C++
Topic: Bigger data type
Replies: 3
Views: 2179

Re: Bigger data type

kiddo wrote:will the grading system recognize gmp lib?
No, UVa judge doesn't allow third-party libraries.
So, the only option I have to code it myself
Yes.

It's not very hard at all, except for the division.
by using string operation?
Using arrays, yes.
by mf
Sun Aug 29, 2010 11:48 pm
Forum: C++
Topic: Bigger data type
Replies: 3
Views: 2179

Re: Bigger data type

kiddo wrote:Is there a data type like Java Big Integer in C++?
No. Write one, or use a third-party library such as gmp.
by mf
Thu Aug 26, 2010 11:07 am
Forum: Other words
Topic: Epsilon
Replies: 3
Views: 4161

Re: Epsilon

Floating point types have a finite precision, and so they typically represent values with some round-off error. You should add/subtract some small value (epsilon) during comparison of floats in order to tolerate this error. E.g. instead of "a < b", it's better to write "a < b - EPS", and instead of ...
by mf
Sun Jan 24, 2010 1:04 am
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 168349

Re: 100

Not all control paths in your np() function return a value. Unlike some other languages (like Lisp, where functions return value of last statement), in C/C++ you must explicitly use a "return <expression>;" statement to return some value from a function. If control exits a function but not through a...
by mf
Wed Jan 06, 2010 8:41 am
Forum: Other words
Topic: Problems: Programming Challenges Input/Output Filenames
Replies: 3
Views: 4120

Re: Problems: Programming Challenges Input/Output Filenames

Your program is supposed to read from standard input and write output to standard output (see http://en.wikipedia.org/wiki/Standard_streams). No files needed.
by mf
Tue Oct 27, 2009 9:09 pm
Forum: Volume 5 (500-599)
Topic: 515 - King
Replies: 5
Views: 2385

Re: 515

You are welcome to translate it if you want. Larry most likely won't mind. Translation's page name should probably be http://www.algorithmist.com/index.php/ru/UVa_515

Go to advanced search