Pagini recente » Cod sursa (job #701407) | Cod sursa (job #688692) | Cod sursa (job #2734922) | Cod sursa (job #777801) | Cod sursa (job #6216)
Cod sursa(job #6216)
#include<fstream.h>
#define input "fact.in"
#define output "fact.out"
int main()
{
long h,x,n;
int gr;
ifstream fin(input);
ofstream fout(output);
fin>>n;
x=n;
h=1;
gr=0;
if(n==0)
fout<<"0/n";
else
while(h*5+1<=n)
{
h=(h*5)+1;
gr++;
}
if(n+gr>=(h*5)+1)
fout<<"-1"<<"\n";
else
{
while(h!=1)
{
x-=(x/h);
h--;
h=h/5;
}
fout<<x*5<<"\n";
}
return 0;
}