Page 2 of 3

Posted: Sun Dec 22, 2002 1:36 pm
by anupam
whenever printing you should consider the last line specially.
there may be a \n after last input, may not. it's main cause of pe
thanks.

Posted: Sun Jan 05, 2003 12:05 am
by Jalal
I think there is a little tric with the prob.
if anyone just findout the number of power of two and
five and deduct them till that number from 2
and do mod in every section that make the solve faster.
:wink:

Posted: Wed Apr 09, 2003 7:33 am
by ridwan
i think you should divide with 10000 instead of 10

Posted: Fri Jul 11, 2003 9:45 am
by Observer
-- Post removed by Observer --

Posted: Fri Jul 11, 2003 10:21 am
by Observer
-- Post removed by Observer --

568 Why PE?

Posted: Sat Jul 12, 2003 1:47 pm
by Rene
why my answer always gets PE?
[cpp]
#include <iostream.h>
#include <stdio.h>

int main()
{
long n,i,b;
while (cin >> n)
{
b = 1;
for (i = 1;i <= n;i++)
{
b *= i;
while (!(b % 10))
b /= 10;
b %= 100000;
}
while (!(b % 10))
b /= 10;
b %= 10;
printf ("%5ld -> %ld\n",n,b);
}
return 0;
}[/cpp]

Posted: Mon Jul 21, 2003 2:42 pm
by Observer
I got PE as well...

I'm quite sure that the judge is wrong on this issue (Look at the statistics!) :P

You don't need to calculate the entire number!

Posted: Tue Dec 16, 2003 1:04 pm
by danielrocha
Just to remind you guys that are trying to solve this problem: you don't need to calculate the entire number! It would be so big that it would not fit into any data type, and you don't need to implement "string array" or a "big int" class..

Since you only want the final digit, why bother with the rest of them? :D

I hope this helps someone! :roll:

Posted: Thu Aug 05, 2004 9:36 am
by jackie
Just factor 2 and factor 5 make 0s in the result and obviously factor 2 is more than factor 5 in the factorial.
Think about the last digits which don't contain 2 or 5s then add num(2) - num(5) 2s to the result and get the answer.

num(n) how many factor ns in the factorial.

hope it can help

good luck

Posted: Fri Jun 17, 2005 8:24 pm
by jaracz
It's impossible!
I got AC with same loop
take a look

Code: Select all

while(scanf("%d",&n)==1)
{
     printf("%5d -> %d\n",n,proc(n));
}
Strange?!

Keep getting WA !!!

Posted: Mon Oct 03, 2005 5:59 pm
by nymo
Hi, i am getting WA in this problem, i tried several inputs and it seems okay, I tried to precalculate the last digit, what is wrong with my code ???

Code: Select all

ACC NOW :D, code removed...
I submitted it several times with different modification and every time its WA. Can anyone help me to find me my bug or with some i/o for which this code fails ?

Thanks in advance ...

I need help on this !!!

Posted: Sun Oct 09, 2005 1:25 pm
by nymo
I 've tried several ways and it is still WA. Any critical I/O for which my above program fails will be a great help. Can you help me to find me my bugs (coz i 've failed to find :( )??? Thanks anyway.

EDIT: ACC now :D

568 how to reduce the run time? anyone can help me ?

Posted: Wed Jan 25, 2006 5:31 pm
by athlon19831
i found the run time is too long.
this is my code:
#include "iostream.h"
#include "stdio.h"

int main(int argc, char* argv[])
{
long n;
long sum;
long i;
while(cin>>n)
{
sum=1;
for(i=n;i>0;i--)
{
sum*=i;
}
while(sum>0)
{
if(sum%10!=0)
{
cout<<sum%10<<endl;
sum/=10;
break;
}
else
sum/=10;
}
}
return 0;
}

Posted: Wed Jan 25, 2006 5:58 pm
by mamun
Use an array to precalculate values upto 10000.

Posted: Tue Jan 31, 2006 6:34 am
by mohiul alam prince
Hi athlon19831

Have you checked your sample input and output.

Code: Select all

sum=1; 
for(i=n;i>0;i--) 
{ 
     sum*=i; 
} 
your this part is totally wrong. (when you multiply the value at that time it exceed the integer range) Try to solve this problem in another approch.

Thanks
MAP.