Cod sursa(job #223742)

Utilizator cercelcercel maria luiza cercel Data 29 noiembrie 2008 12:19:01
Problema Factorial Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.39 kb
#include<iostream.h>
#include<fstream.h>
fstream f,g;
long p,n,i,k;
long nrdiv5(long x){
long s=0;
while(x%5==0)
{s++;
x=x/5;}
return s;}
int main  (){
f.open("fact.in",ios::in);
f>>p;
f.close();
g.open("fact.out",ios::out);
if(p==0)
{n=1;
g<<n;
g.close();
}
else{
n=0;
k=0;
while(k<p){
n=n+5;
k=k+nrdiv5(n);
}
if(k==p)
g<<n;
else
g<<-1;
g.close();
}
return 0;}