Cod sursa(job #12968)
Utilizator | Data | 5 februarie 2007 12:56:46 | |
---|---|---|---|
Problema | Factorial | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.37 kb |
#include<fstream.h>
int main(){
ifstream in("fact.in");
ofstream out("fact.out");
long n,p,i,s=0,x=0,j=1,y=1;
in>>p;
i=1;
if(p==0)
out<<1<<"\n";
else
{
while(s!=p)
{
i=1;
while(y%5==0)
{y=y/5;
i++;}
s=s+i;
x++;
j++;
y=j;
if(s>p)
out<<-1<<"\n";
}
out<<x*5<<"\n";}
in.close();
out.close();
return 0;
}