10323 - Factorial! You Must be Kidding!!!

All about problems in Volume 103. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Tue Jun 19, 2007 9:43 am

13! = 6227020800, which exceeds integer limit.
Ami ekhono shopno dekhi...
HomePage

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

CE....

Post by Obaida » Sat Mar 01, 2008 7:32 am

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;
}
try_try_try_try_&&&_try@try.com
This may be the address of success.

User avatar
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind » Sat Mar 01, 2008 8:36 am

Obaida, I submitted your code, and got Wrong answer. Did you select proper language option before submit?

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

WA.....

Post by Obaida » Sat Mar 01, 2008 8:46 am

some one please help me still I got WA....
Last edited by Obaida on Sat Mar 01, 2008 12:54 pm, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.

User avatar
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind » Sat Mar 01, 2008 8:48 am

So did you get accepted?

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Still WA...

Post by Obaida » Sat Mar 01, 2008 12:21 pm

But still........I got WA... Hear is my code........

Code: Select all

Code removed
}
Last edited by Obaida on Sun Mar 02, 2008 5:35 am, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.

User avatar
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind » Sat Mar 01, 2008 2:09 pm

try this input

Code: Select all

7

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Oh....no..

Post by Obaida » Sun Mar 02, 2008 5:34 am

Code: Select all

Actually I mistake to read the problem......HA....Ha...Ha...
try_try_try_try_&&&_try@try.com
This may be the address of success.

User avatar
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Re: Oh....no..

Post by emotional blind » Sun Mar 02, 2008 10:55 am

Obaida wrote:

Code: Select all

Actually I mistake to read the problem......HA....Ha...Ha...
Are you happy with that? or proud? :o

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Ok

Post by Obaida » Wed Mar 05, 2008 8:26 am

My smile doesn't meen my happyness or my proud... It means How much I had to be careful.
try_try_try_try_&&&_try@try.com
This may be the address of success.

User avatar
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind » Wed Mar 05, 2008 9:53 am

Be Careful, Be Happy :)

chenaren
New poster
Posts: 1
Joined: Sun Nov 30, 2008 6:39 am

Re: 10323 - Factorial! You Must be Kidding!!!

Post by chenaren » Sat Dec 13, 2008 1:22 pm

1/0 is not defined rather than infinite

the problem may have bad influence on the mathematical concept of the solver

:-?

sefakilic
New poster
Posts: 7
Joined: Wed Mar 11, 2009 8:12 pm

Re: 10323 - Factorial! You Must be Kidding!!!

Post by sefakilic » Wed Mar 11, 2009 8:17 pm

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..

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 10323 - Factorial! You Must be Kidding!!!

Post by Obaida » Thu Mar 12, 2009 6:32 am

I didn't checked your code. But i think you should use long long. :)
try_try_try_try_&&&_try@try.com
This may be the address of success.

sefakilic
New poster
Posts: 7
Joined: Wed Mar 11, 2009 8:12 pm

Re: 10323 - Factorial! You Must be Kidding!!!

Post by sefakilic » Fri Mar 13, 2009 3:46 pm

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.

Post Reply

Return to “Volume 103 (10300-10399)”