Cod sursa(job #305620)
Utilizator | Data | 17 aprilie 2009 22:22:58 | |
---|---|---|---|
Problema | Factorial | Scor | 95 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.59 kb |
#include<fstream.h>
int i,j,p,k,l,m,n;
int main(){
ifstream f("fact.in");
ofstream g("fact.out");
f>>p;
while((i+j)<p)
{i+=5;
m=i;
while(m%5==0)
{
m/=5;j++;
}
}
while(i+j>p)
{m=i;
while(m%5==0)
{m/=5;
j--;}
i--;
}
k=i+j;
if(k==p)
g<<i*5;
else
g<<-1;
f.close();
g.close();
return 0;
}