Page 6 of 8
Posted: Tue Jun 19, 2007 9:43 am
by Jan
13! = 6227020800, which exceeds integer limit.
CE....
Posted: Sat Mar 01, 2008 7:32 am
by Obaida
Some one please help me I am getting CE.....
Code: Select all
#include<stdio.h>
int main()
{
long double fact,i,n,count;
while(scanf("%Lf",&n)==1)
{
fact=1;
count=1;
for(i=1;i<=n;i++)
{
fact=fact*i;
if(fact>6227020800)
{
count=0;
printf("Overflow!\n");
break;
}
}
if(count!=0)
{
if((fact/1000)<1)
{
printf("Underflow!\n");
}
else
{
printf("%.0Lf\n",fact);
}
}
}
return 0;
}
Posted: Sat Mar 01, 2008 8:36 am
by emotional blind
Obaida, I submitted your code, and got Wrong answer. Did you select proper language option before submit?
WA.....
Posted: Sat Mar 01, 2008 8:46 am
by Obaida
some one please help me still I got WA....
Posted: Sat Mar 01, 2008 8:48 am
by emotional blind
So did you get accepted?
Still WA...
Posted: Sat Mar 01, 2008 12:21 pm
by Obaida
But still........I got WA... Hear is my code........
Posted: Sat Mar 01, 2008 2:09 pm
by emotional blind
Oh....no..
Posted: Sun Mar 02, 2008 5:34 am
by Obaida
Code: Select all
Actually I mistake to read the problem......HA....Ha...Ha...
Re: Oh....no..
Posted: Sun Mar 02, 2008 10:55 am
by emotional blind
Obaida wrote:Code: Select all
Actually I mistake to read the problem......HA....Ha...Ha...
Are you happy with that? or proud?

Ok
Posted: Wed Mar 05, 2008 8:26 am
by Obaida
My smile doesn't meen my happyness or my proud... It means How much I had to be careful.
Posted: Wed Mar 05, 2008 9:53 am
by emotional blind
Be Careful, Be Happy

Re: 10323 - Factorial! You Must be Kidding!!!
Posted: Sat Dec 13, 2008 1:22 pm
by chenaren
1/0 is not defined rather than infinite
the problem may have bad influence on the mathematical concept of the solver

Re: 10323 - Factorial! You Must be Kidding!!!
Posted: Wed Mar 11, 2009 8:17 pm
by sefakilic
I've read all posts in this topic.
I believe that I am doing right, but unfortunately I don't. I am getting WA.
Here is my code:
Code: Select all
#include "stdio.h"
unsigned long iter_factorial(int n) {
unsigned long accu = 1;
unsigned long i;
for(i = 1; i <= n; i++) {
accu *= i;
}
return accu;
}
int main() {
unsigned long x;
int a;
while( scanf("%d", &a) != EOF )
{
if( a <= 7 && a >= 0)
printf("Underflow!\n");
else if(a > 13)
printf("Overflow!\n");
else if(a < 0)
{
if( a / 2 * 2 == a)
printf("Underflow!\n");
else
printf("Overflow!\n");
}
else {
x = iter_factorial(a);
printf("%lu\n",x);
}
}
return 0;
}
Thank you..
Re: 10323 - Factorial! You Must be Kidding!!!
Posted: Thu Mar 12, 2009 6:32 am
by Obaida
I didn't checked your code. But i think you should use long long.

Re: 10323 - Factorial! You Must be Kidding!!!
Posted: Fri Mar 13, 2009 3:46 pm
by sefakilic
My factorial function calculates the factorials of numbers between 8 and 13 [including them]. But I was getting WA.
I replaced the factorial function with the precalculated values. ( if (x == 8 ) printf("...") .....)
And I got AC.