You must check that scanf returns 1 here.while(scanf("%ld",&n)){
Search found 1242 matches
- Mon Jan 03, 2011 7:48 pm
- Forum: Volume 5 (500-599)
- Topic: 583 - Prime Factors
- Replies: 171
- Views: 42580
Re: 583 - Prime Factors
scanf may return 0 or -1 on failure. So this line is wrong:
- Sun Nov 21, 2010 1:57 am
- Forum: Volume 100 (10000-10099)
- Topic: 10055 - Hashmat the Brave Warrior
- Replies: 166
- Views: 51875
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.
But it's more usual to just read and solve the test cases one-by-one.
- Wed Nov 10, 2010 1:10 pm
- Forum: Volume 10 (1000-1099)
- Topic: 1055 - Pockets
- Replies: 3
- Views: 6031
Re: First Java prog submission Compilation Error
Your class should be called Main.
- Fri Nov 05, 2010 6:28 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10055 - Hashmat the Brave Warrior
- Replies: 166
- Views: 51875
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.
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.
- Fri Nov 05, 2010 2:55 am
- Forum: Volume 100 (10000-10099)
- Topic: 10055 - Hashmat the Brave Warrior
- Replies: 166
- Views: 51875
Re: cannot the understand the mistake
No, it ain't.
- Tue Oct 05, 2010 9:20 pm
- Forum: Other words
- Topic: Do there exist any RE reports?
- Replies: 2
- Views: 3485
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...
- Sat Oct 02, 2010 5:39 pm
- Forum: Algorithms
- Topic: Circular String Linearization
- Replies: 12
- Views: 13674
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
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
- Tue Sep 07, 2010 10:50 pm
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 217043
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.
- Sat Sep 04, 2010 4:43 pm
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 217043
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)".
I think the error is here - "while (scanf("%d %d", &i, &j))". It must be "while (scanf("%d %d", &i, &j) == 2)".
- Mon Aug 30, 2010 11:53 pm
- Forum: C++
- Topic: Bigger data type
- Replies: 3
- Views: 2572
Re: Bigger data type
No, UVa judge doesn't allow third-party libraries.kiddo wrote:will the grading system recognize gmp lib?
Yes.So, the only option I have to code it myself
It's not very hard at all, except for the division.
Using arrays, yes.by using string operation?
- Sun Aug 29, 2010 11:48 pm
- Forum: C++
- Topic: Bigger data type
- Replies: 3
- Views: 2572
Re: Bigger data type
No. Write one, or use a third-party library such as gmp.kiddo wrote:Is there a data type like Java Big Integer in C++?
- Thu Aug 26, 2010 11:07 am
- Forum: Other words
- Topic: Epsilon
- Replies: 3
- Views: 4838
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&qu...
- Sun Jan 24, 2010 1:04 am
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 217043
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...
- Wed Jan 06, 2010 8:41 am
- Forum: Other words
- Topic: Problems: Programming Challenges Input/Output Filenames
- Replies: 3
- Views: 4744
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.
- Tue Oct 27, 2009 9:09 pm
- Forum: Volume 5 (500-599)
- Topic: 515 - King
- Replies: 5
- Views: 2741
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