Uva 10323 – Factorial! You Must be Kidding!!!

Problem:- http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=24&problem=1264&mosmsg=Submission+received+with+ID+10597223

Solution :-

#include<stdio.h>
int main()
{
long long n;
while(scanf(“%lld”,&n)==1)
{
if(n<0&&n%2==0)
printf(“Underflow!n”);
else if(n<0&&n%2!=0)
printf(“Overflow!n”);
else if(n==0||n<=7)
printf(“Underflow!n”);
else if(n==8)
printf(“40320n”);
else if(n==9)
printf(“362880n”);
else if(n==10)
printf(“3628800n”);
else if(n==11)
printf(“39916800n”);
else if(n==12)
printf(“479001600n”);
else if(n==13)
printf(“6227020800n”);
else if(n>13)
printf(“Overflow!n”);
}
return 0;
}
At First you can try to solve this problem if you can’t than see this code & find what’s your problem . If you copy paste this code you could not improve yourself in programming .

Posted by Shipu Ahamed

1 comment

how odd negative will give overflow and even gives underflow

Leave a Reply