Page 2 of 8

Posted: Tue Nov 05, 2002 2:31 am
by zhangl
why die i got wrong?
who can help me?

Posted: Tue Nov 05, 2002 5:30 am
by turingcomplete
To the problem setter: thanks for wasting an hour of time. If you want to make up some function then don't call it factorial, as it's really confusing to those of us who know that factorial is only defined for 0+.

:x

Posted: Thu Nov 07, 2002 9:52 am
by Ghost77 dimen
Come on, turingcomplete. 8)

The title is so clear that it play a trick on us.

Didn't you think for a while why it said that " You must be kidding."?

8)

10323

Posted: Wed Feb 05, 2003 5:17 pm
by ec3_limz
Why WA? :roll:

[cpp]#include <iostream.h>
typedef unsigned long long ULLT;

int main() {
const ULLT UNDER = 10000LL, OVER = 6227020800LL;
ULLT limit, fact, i;

while (cin >> limit) {
fact = 1;
for (i = 1; i <= limit; i++) {
fact *= i;
if (fact > OVER) {
cout << "Overflow!\n";
break;
}
}

if (fact <= OVER) {
if (fact < UNDER)
cout << "Underflow!\n";
else
cout << fact << '\n';
}
}

return 0;
}[/cpp]

Posted: Thu Feb 06, 2003 6:25 am
by angga888
The problem doesn't state the minimum input, so you must handle negative factorial, like : -1!, -2!, -3!, ...
To find the answer of that problem, just simulate this formula :
(n-1) ! = n ! / n

Good Luck ! :D

Posted: Fri Feb 07, 2003 1:55 am
by knightmare
For negative numbers it's always underflow or overflow (depends on whether the number is even or odd).

This problem is completely stupid (mathematically incorrect), as you can read on this thread:

http://acm.uva.es/board/viewtopic.php?t=803

You can start flaming me for posting the "solution" here, I don't care... People shouldn't be supposed to guess, only to think about logical things.

P 10323

Posted: Fri Feb 07, 2003 7:54 am
by Red Scorpion
How if the input is :
Input :
-1
-2
-3

Ouput:
Overflow
Underflow
Overflow

Is This Right ?
Regards,
RED SCORPION :lol:

Posted: Fri Feb 07, 2003 12:17 pm
by Red Scorpion
Yes, I Got AC,
when it is a negative number, I look if it is EVEN,
then the output should be Underflow!, else if
it is ODD then the output should be Overflow!

Thanks,
RED SCORPION :lol:

Posted: Fri Feb 07, 2003 12:20 pm
by angga888
Yes, you're right, Red Scorpion. :D
And that pattern will repeat again and again (for negative factorial).
However, I still think that negative factorial is undefined. :wink:

Give some explanation

Posted: Fri Feb 21, 2003 8:26 pm
by razibcse
I can't understand how to calculate factorial of negative numbers...if u put n=0 in the formula (n-1)!=n!/n, u get
-1!=0!/0...how is this possible?

pls give some explanation of the process how negative even numbers get Underflow! and odd numbers get Overflow!...


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Razib
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Our lives improve only when we take chances - and the first and most
difficult risk we can take is to be honest with ourselves.[/quote]

Posted: Sat Feb 22, 2003 8:34 pm
by Jalal
Yes! no doubt about it!
One of the most stupid problem it is!
As far i know acm is for updating our brain.
Not for damage our topic's with bad theory
just to make a problem ubsolved :x

Posted: Wed Apr 16, 2003 7:15 pm
by VitorRodrigues
Hisoka and razibcse, you do not have to use any formula to calculate factorial of negative numbers. Jus print "Overflow!" if the number is odd, or "Underflow!" if the number is even.

Good luc :)

Posted: Thu Apr 17, 2003 6:08 am
by Eric
I get WA.
I think the problem is :
  • It used to contain the correct algorithm, but I deleted.
Can anyone help me?

Posted: Thu Apr 17, 2003 7:39 am
by little joey
Eric: You do Pascal, don't you? PM me your code, and I'll have a look.

Posted: Thu Apr 17, 2003 12:41 pm
by Eric
I get Accepted now. Thanks Joey.
It is really a careless mistake.