Cod sursa(job #491000)
| Utilizator | Data | 9 octombrie 2010 11:24:29 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.62 kb |
#include<iostream.h>
#include<fstream.h>
int main()
{
fstream f("factorial.in", ios::in);
fstream g("factorial.out", ios::out);
long int P,x,y,N,a;
int h;
f>>P;
if(P==0)
g<<1;
else
{
for(N=1,h=0,x=0,y=0; h!=1; N++)
{
a=N;
while(a%2==0)
{
a=a/2;
x++;
}
while(a%5==0)
{
a=a/5;
y++;
}
if(x<y)
if(x==P)
{
h=1;
g<<N;
}
else
if(y==P)
{
h=1;
g<<N;
}
if(x>P && y>P)
{
h=1;
g<<"-1";
}
}
}
}